Re: [R] where does R search when source()?

From: Duncan Murdoch <dmurdoch_at_pair.com>
Date: Mon 12 Jul 2004 - 03:12:31 EST

I wrote:

>I agree that this is a good use for a script, but I don't think it's
>what Daehyok was talking about. He wants a library of frequently used
>scripts to be available in multiple projects. In R, the best way to
>do that isn't to use scripts at all, it's to put the code in
>functions.

On Sun, 11 Jul 2004 12:41:20 -0400, "Shin, Daehyok" <sdhyok@email.unc.edu> wrote:

>What I asked is the way to set up default search paths for source function,
>whether or not files in the paths contain a set of functions or simple
>script code.

Gabor gave you a way to do that. I was responding to your suggestion that R should be modified to make this more convenient, because

>To my knowledge, it is a common practice for users to archive some script
>files in other directories than current working directory, when the script
>files are frequently used in many cases. So, it is somewhat surprising to me
>there is no elegant solution to set up default search paths in R.

I don't think this is a common practice; if it is, it shouldn't be. Frequently used code should be in functions. There are a lot of ways to get those functions into your workspace, but R packages are the best one. There *is* a mechanism (the .libPaths function) for specifying a search path for packages.

Duncan Murdoch



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jul 12 03:22:56 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:50 EST