On 19-Jun-06 Rob Campbell wrote: > Hi, > > I have to R fairly recently from Matlab, where I have been used to > organising my own custom functions into directories which are adding to > the Matlab search path. This enables me to call them as I would one of > Matlab's built-in functions. I have not found a way of doing the same > thing in R. I have resorted to using source() on symlinks located in > the > current directory. Not very satisfactory. > > I looked at the R homepage and considered making a "package" of my > commonly used functions so that I can call them in one go: > library(myFuncions, lib.loc="/path/to/library") Perhaps this is the > only > solution but the docs on the web make the process seem rather > complicated--I only have a few script files I want to call! Surely > there's a straightforward solution? > > How have other people solved this problem? Perhaps someone has a simple > "package skeleton" into which I can drop my scripts? > > > Thanks, > > Rob
There are pros and cons to this, but on the whole I sympathise with you (having pre-R been a heavy matlab/octave user myself). Unfortunately (from this perspective) R does not seem to have an automatic "load-on-demand" facility similar to what happens in matlab (i.e. you call a function by name, and R would search for it in whatever the current search-path is, and load its definition plus what else it depends on). I have a few definitions which I want in every R session, so I have put these in my ".Rprofile". But this is loaded from my home directory, not from the directory where I was when I started R, so it is the same every time. Again, one of the conveniences of the matlab/octave approach is that you can have a different sub-directory for each project, so if you start work in a particular one then you have access to any special definitions for that project, and not to others. I'm no expert on this aspect of R, but I suspect that the way start-up is organised in R does not fit well with the other kind of approach. I stand to be corrected, of course ... And others may well have formulated their own neat work-rounds, so we wait eagerly to hear about these! Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 19-Jun-06 Time: 11:25:15 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html