[R] functions & paths
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Apr 1 02:55:14 CEST 2004
Don MacQueen <macq at llnl.gov> writes:
> 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.
- 3 -
dump(c("fun1","fun2","fun3"),"path/to/myfuns.R")
and
source("path/to/myfuns.R")
to get them into another session. (Can you even get started with -2-
without knowing this??)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list