Skip to content

Instantly share code, notes, and snippets.

@klmr
Created April 3, 2013 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klmr/5301304 to your computer and use it in GitHub Desktop.
Save klmr/5301304 to your computer and use it in GitHub Desktop.
(Incomplete) simple module mechanism for R.
import <- function (module) {
module <- as.character(substitute(module))
# Search path handling omitted for simplicity.
filename <- paste(module, 'R', sep = '.')
includeGuard <- paste('.INCLUDE', toupper(module), 'R', sep = '_')
if (exists(includeGuard))
return()
assign(includeGuard, TRUE, envir = topenv())
sys.source(filename, chdir = TRUE)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment