[R] sourcing the content of directories

Thomas Lumley tlumley at u.washington.edu
Tue Oct 29 17:38:08 CET 2002


On Tue, 29 Oct 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 ?


  lapply(list.files(dirname, pattern="\\.R$"), "source", local=FALSE)

or more simply (but not a single call)

  for(name in list.files(dirname, pattern="\\.R$"))
	source(name)

This will source() them in lexicographic order.


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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