Python is known for a stellar module and import system that makes it incredibly easy to manage dependencies and track the etiology of local variables and functions.
This project offers a "port" to R of Python's module system using syberia, a development framework for R.
To create a new python.sy project simply create a directory with this syberia engine:
# config/application.R
name <- "python.sy project"
# config/engines.R
engine("python", type = "github", repo = "syberia/python.sy", mount = TRUE)
You can then start working with R as if it's python:
# toplevel.R
from(first.second.third) %import% c("chocolate", "coconut")
list(
chocolate = chocolate("happy"),
coconut = coconut("delighted")
)
# first/second/third.R
chocolate <- function(adjective) {
sprintf("Chocolate makes me %s!", adjective)
}
coconut <- function(adjective) {
sprintf("Eating coconut leaves one feeling %s.", adjective)
}
Opening the R console from the root of the project, we notice
syberia_engine(".")$resource("toplevel")
# $chocolate
# [1] "Chocolate makes me happy!"
#
# $coconut
# [1] "Eating coconut leaves one feeling delighted."
Check out the repo for this example.