[R] sourcing the content of directories

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Oct 29 16:28:43 CET 2002

Jan Malte Wiener wrote:
> hi,
> is there a way to source all R-files that reside in a given directory
> with a single R-call ?
> greetinx jan

This should do the trick:

 direct <- "/given/directory"
 temp <- dir(direct)
 sapply(paste(direct, temp[grep("[.]R$", temp)], sep = "/"), source)

BTW: Consider to create your own package, if you have a couple of files
you are going to source frequently...

Uwe Ligges
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list