On Tue, Oct 29, 2002 at 12:42:22PM +0100, 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 janJan Given this question, and the previous one about environment variables and file paths, it looks like you really should set your project up as a full R package. While this might be a painful transition under CVS (never have changed file paths mid-project, but I hear it's not trivial), it should be worth it to eliminate headaches like cross-platform file sourcing, and should also ease documentation writing and storage. See the "Writing R Extensions" manual (R-exts.pdf). You might also want to get the book "S Programming", another good one by Venables and Ripley. And *definately* check out the function package.skeleton, which sets up template files for you (very slick, and helps me remember details I might normally overlook). Cheers Jason -- Indigo Industrial Controls Ltd. 64-21-343-545 jasont at indigoindustrial.co.nz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
hi, is there a way to source all R-files that reside in a given directory with a single R-call ? greetinx jan -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 ?Yes, write a function using list.files() to list them, then a for loop or lapply along the list. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 janThis 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._