Theres a package for this purpose called "modules" .
The package provides an import function that easily replaces source . For most purposes
source('x.r')
can simply be replaced by
x = import('x') # or: import('x', attach = TRUE)
However, import does a lot of things better than source - for example, you can arrange your modules hierarchically within a project:
cmdline = import('sys/cmdline') args = cmdline$parse() # or: sys = import('sys') args = sys$cmdline$parse()
See vignette for details .
The modules module was created precisely because I was unsatisfied with Rs support for modulation.
Konrad Rudolph
source share