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

Duncan Murdoch dmurdoch at pair.com
Sun Jul 11 14:25:40 CEST 2004

On Sun, 11 Jul 2004 10:13:52 +0300, Renaud Lancelot
<renaud.lancelot at cirad.fr> wrote:

>I do agree with you: in my opinion, creating a package is not a general 
>solution when you just want to save the script of a whole data analysis 
>for the purpose of, say, a paper or a report.

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

The problem with script code that is not in functions is that it needs
to have hard-coded variable names, and those can have undesirable side
effects.  But if you start R with an empty workspace, then load data
for a particular project from a script, collisions are unlikely.

>To meet this goal, I save the script in a text file and I use a text 
>editor with sourcing facilities (e.g. WinEdt + R-WinEdt, Xemacs + 
>ESS,...: see Software ==> Other section on CRAN).

R for Windows will have such an editor built in with the next major
release (in the fall).

Duncan Murdoch

More information about the R-help mailing list