[R] How to read stored functions

Vladimir Eremeev wl2776 at gmail.com
Tue Sep 25 17:00:31 CEST 2007



Duncan Murdoch-2 wrote:
> 
> On 9/25/2007 4:15 AM, Vladimir Eremeev wrote:
>> source'ing is a bad practice because this saves additional copies of
>> functions and data in the local workspace.
>> 
>> Wasting disk space is not a problem now since HDDs are cheap and function
>> bodies are generally small.
>> 
>> But, when you change any function body, you have to repeat that source()
>> call in local workspace of every project using the functions.
> 
> I disagree.  The bad practice is having local workspaces.  It's easy to 
> see what's in a text file, and hard to see exactly what's in a .RData 
> file, so it's better to keep everything as text.  There are situations 
> where the overhead of converting text to internal objects is too high,
> e.g. the results of long simulation runs may be worth saving in binary 
> form so they're quicker to load.  But you can save objects one (or a 
> few) at a time, you don't need to save everything.
> 

It's the matter of taste. I prefer separate directories for separate
projects. Sometimes I have 'subprojects' with their own workspaces. If I
have large objects, I usually don't analyze them with a text viewer.
And, the last. The option of saving the local workspace exists in R for
years. As one of its developers you know that the R Core Team has the very
strong feedback with users. I don't think that bad features exist in such
conditions for such a long time.


Duncan Murdoch-2 wrote:
> 
> If you find you're using a function in multiple projects, then it's time 
> to build a small package to hold it.  The first line in the scripts for 
> each of those projects can be
> 
> library(MyPackage)
> 
> If you think building a package is too much overhead, you can replace 
> the line above with
> 
> source("path/to/MyFunction.R")
> 
> but this is less portable, since you may not have the function installed 
> in the same directory on every system you use.
> 
> Duncan Murdoch
> 
> 
That's right.
-- 
View this message in context: http://www.nabble.com/How-to-read-stored-functions-tf4513863.html#a12881540
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list