On 25/03/11 09:08, Thomas Lumley wrote:
On Fri, Mar 25, 2011 at 5:11 AM, David.Epstein
<david.epst...@warwick.ac.uk> wrote:
Hello, I don't want to find out how to make packages unless that becomes
necessary. Also, I don't want to clog up the computer memory with functions
that I'm not using. (It would be great if someone in this forum would
explain how memory is used when I type library(MASS) and then use only one
function from MASS. Are all the many MASS functions then residing in memory,
or only the one I called?)
There is a lazy-loading system that loads functions and datasets only
on demand. Not all packages use it, but MASS does.
Is there some standard way of
1. storing the R functions that I define, each in a separate file in some
standard directory, and then
2. calling one of these functions without having to include the path to the
relevant directory?
3. If so, are there conventional places to keep such files, akin to
/usr/local/bin in Unix?
No.
You really do want to learn to make packages. It isn't that hard.
However, another possibility is to use save() to save a file
containing all your functions and then use attach() to make these
functions available. This works like making a package except that you
don't get lazy-loading, you don't get documentation, and you don't get
the package checks.
-thomas
Another work around would involve defining a little function in your
.Rprofile, as follows.
Choose a location for your code. The function would take the name of the
file, prepend the path to the directory where your code is located and
then call source. Two or three lines would do it.
Also, who knows, maybe Gabor has something clever in his batch files, he
usually seems to.
David Scott
--
_________________________________________________________________
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142, NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018
Director of Consulting, Department of Statistics
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.