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

From: Duncan Murdoch <dmurdoch_at_pair.com>
Date: Sun 11 Jul 2004 - 22:25:40 EST

On Sun, 11 Jul 2004 10:13:52 +0300, Renaud Lancelot <renaud.lancelot@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 functions.

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



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 Sun Jul 11 22:33:15 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:35:33 EST