This package provides a mechanism to import R scripts as a package, in other words, with namespace.
First, install namespace
package used in packageR
.
$ Rscript -e 'install.packages("namespace")'
Then, clone the repository and install the package.
$ git clone [email protected]:abicky/packageR.git
$ R CMD INSTALL packageR
import(files, as)
See also ?import
You have to call export
function to export the variables in the specified scripts like below:
f <- function() print("function f")
export(f)
files <- system.file("examples", c("public.R", "private.R"), package = "packageR")
import(files, "foo")
# exported function
foo::f()
# unexported function
foo:::.f()
unloadNamespace("foo")