Skip to content
Prev 310145 / 398502 Next

save/load and package namespaces

On 07/11/2012 12:50 PM, Jamie Olson wrote:
None are loaded or saved when you save the object, but the names of some 
are saved.  For example,

library(Hmisc)  # not normally loaded/attached
x <- zoom # copy a function from Hmisc
save(x, file="x.RData")

This will save a copy of a function from Hmisc to the file, but the 
function's environment is the Hmisc namespace.  To properly load that 
function via

load("x.RData")

R will load the referenced namespace.  You will see it appear in 
loadedNamespaces() after the load (assuming you still have Hmisc available).

I believe this will also happen if you try to load an S4 object; you'll 
need to be able to load the namespace of its class.

Duncan Murdoch