[R] Can you save an installed library to an .RData file?
Duncan Murdoch
murdoch.duncan at gmail.com
Thu Jul 21 17:46:06 CEST 2011
On 21/07/2011 11:37 AM, Gene Leynes wrote:
> It occurred to me that it would be nice to be able to save a library that I
> have installed an loaded into my workspace for easy sharing. I suppose it
> might not work if someone's on a different version of R, but usually since
> the library is just a collection of functions, it seems plausible that you
> could just save the functions into your workspace.
You could save the functions, but they probably won't work: their
environments will be the namespace of the package they came from.
You'd be much better off copying the source of the functions into your
own package. Most packages have licenses that allow that.
>
> I'm sure this question is a bit naive, but I would be happy to have
> references on the best place to read up on it and advice on where to focus.
>
> Couldn't you iterate over the search() environments (skipping the base
> packages), save the name of the environment and the functions, and then
> unpack them when you load the new workspace.
Many packages have functions that are not visible when the package is
attached to the search() list, so that would not work.
Duncan Murdoch
More information about the R-help
mailing list