Re: [R] save/load and package namespaces

2012-11-14 Thread Jamie Olson
Thanks, I'd started to look through serialize.c but got a bit lost. Thanks again! Jamie Olson On Tue, Nov 13, 2012 at 2:12 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 13/11/2012 1:45 PM, Jamie Olson wrote: Correct me if I'm wrong, but it also seems that more generally, everything

Re: [R] save/load and package namespaces

2012-11-13 Thread Jamie Olson
Correct me if I'm wrong, but it also seems that more generally, everything works as long as the environment is 'below' .GlobalEnv. For example, x = function(){ y = 4 function()y } yfun = x() save(yfun,file = yfun.RData) load(yfun.RData) yfun() This works fine even when there are more

Re: [R] save/load and package namespaces

2012-11-13 Thread Duncan Murdoch
On 13/11/2012 1:45 PM, Jamie Olson wrote: Correct me if I'm wrong, but it also seems that more generally, everything works as long as the environment is 'below' .GlobalEnv. For example, x = function(){ y = 4 function()y } yfun = x() save(yfun,file = yfun.RData) load(yfun.RData) yfun()

[R] save/load and package namespaces

2012-11-07 Thread Jamie Olson
Could someone explain to me what namespaces are loaded/saved when objects are saved? Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. Later, loading it on another machine, I'm surprised to see

Re: [R] save/load and package namespaces

2012-11-07 Thread Jamie Olson
Could someone explain to me what namespaces are loaded/saved when objects are saved? Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. Later, loading it on another machine, I'm surprised to see

Re: [R] save/load and package namespaces

2012-11-07 Thread Jeff Newmiller
Stop being surprised. Loaded packages are not part of envir (whatever that is), nor are they part of the global environment. You have to reload any packages needed separately from the load call. --- Jeff Newmiller

Re: [R] save/load and package namespaces

2012-11-07 Thread David Winsemius
On Nov 7, 2012, at 9:50 AM, Jamie Olson wrote: Could someone explain to me what namespaces are loaded/saved when objects are saved? None. That's what require() or library() or source() are for. Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name,

Re: [R] save/load and package namespaces

2012-11-07 Thread Duncan Murdoch
On 07/11/2012 12:50 PM, Jamie Olson wrote: Could someone explain to me what namespaces are loaded/saved when objects are saved? 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

Re: [R] save/load and package namespaces

2012-11-07 Thread Duncan Murdoch
On 12-11-07 6:20 PM, Jamie Olson wrote: Thank you! This explains the error thrown by getNamespace() for the missing package. So I imagine this will happen for any function's environment? Do you know if this should happen for S3 objects or just S4? It should only happen for objects that have

Re: [R] save/load and package namespaces

2012-11-07 Thread Jamie Olson
Thank you! This explains the error thrown by getNamespace() for the missing package. So I imagine this will happen for any function's environment? Do you know if this should happen for S3 objects or just S4? Jamie Olson On Wed, Nov 7, 2012 at 4:10 PM, Duncan Murdoch