[R] functions & paths

Don MacQueen macq at llnl.gov
Thu Apr 1 02:06:22 CEST 2004


At 5:28 PM -0500 3/31/04, Kissell, Robert [EQRE] wrote:
>Hi,
>I have a couple of quick questions regarding R.
>

<- snip ->

>3) Is there anyway that I could save functions that I have written 
>outside of R. That is, could I write functions and have them saved 
>in some directory, such as, C:\Programs\RLanguage\RobFunctions\? 
>This way I would be able to copy the functions to other pcs. This is 
>very simple in MatLab. Please let me know.

Yes. Here are two ways.

  - 1 -
In the directory where you have your function definitions, load the 
functions into R. Quit R, and say "yes" when asked whether or not to 
save the workspace image. Find the file in which the image is saved, 
copy it to the other pcs. On the other pcs, use the "attach" function 
to attach that file. The functions are now available.

-2-
Go get the R Extensions manual, learn how to create a package. Take 
your functions, make them into a package. Copy the package file to 
the other pcs. Use R's "install package" functionality to install the 
package. Then, whenever the functions are needed, use the "library" 
command to load your package.



>Thanks for the help.
>
>Rob
>


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA




More information about the R-help mailing list