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 the load failing for being unable to load certain packages. Could anyone help me understand why this happens? Jamie Olson [[alternative HTML version deleted]]
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 the load failing for being unable to load certain packages. Could anyone help me understand why this happens? Jamie Olson [[alternative HTML version deleted]]
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 The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Jamie Olson <inspired2apathy at gmail.com> wrote:>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 the load >failing >for being unable to load certain packages. Could anyone help me >understand >why this happens? >Jamie Olson > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
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, envir > envir) > to save out everything from an environment.You need to read more carefully: ?ls ?objects ?search> > Later, loading it on another machine, I'm surprised to see the load failing > for being unable to load certain packages. Could anyone help me understand > why this happens?`ls` with default settings only lists data and function objects that the user has defined. The history mechanism could be used to restore packages that were loaded during a session. ?history You should be able to see this by looking at what ls() produces. It does not generally return a listing of items in loaded packages. -- David Winsemius, MD Alameda, CA, USA
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 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> > 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 the load failing > for being unable to load certain packages. Could anyone help me understand > why this happens? > Jamie Olson > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Apparently Analagous Threads
- Scope and apply-type functions
- List S3 methods and defining packages
- How to understand packages, namespaces, environments
- Newbie - Summarize function
- Increase transparency: suggestion on how to avoid namespaces and/or unnecessary overwrites of existing functions