I have two packages, one that does the actual work (SC) and the other a Tcl/Tk UI (SCUI) that invokes methods within the former. Within the SCUI's invocation method, I save an object returned from SC, the results of a long-running method. Now the object is completely described by the SC package. Unfortunately, any attempt to load the object (in a fresh R session) fails as below. R> library(SC) R> setwd("/path/to/results/") R> load("sc-results.rda") Loading Tcl/Tk interface ... done Error: .onLoad failed in loadNamespace() for 'SCUI', details: call: optiondb_add("*Notebook.borderWidth", 2, "widgetDefault") error: could not find function "tcl" That call (which adds resource to Tcl resource database) is made inside SCUI. Loading tcltk package removes the problem. R> library(tcltk) R> load("sc-results.rda") R> ls() [1] "results" But I would really prefer not to need to load tcltk at all just to inspect/use the object, which contains nothing from SCUI anyway. Is there a way to strip the unwanted UI prerequisite (tcltk and SCUI) packages from the environment of the object prior/during save()? R version 2.11.1 Patched (2010-06-03 r52201) x86_64-apple-darwin9.8.0
Martin Maechler
2010-Aug-25 07:42 UTC
[Rd] save() object w/o all of the loaded environment
>>>>> "RL" == Roebuck,Paul L <proebuck at mdanderson.org> >>>>> on Tue, 24 Aug 2010 11:06:54 -0500 writes:RL> I have two packages, one that does the actual work (SC) RL> and the other a Tcl/Tk UI (SCUI) that invokes methods RL> within the former. Within the SCUI's invocation method, RL> I save an object returned from SC, the results of a RL> long-running method. RL> Now the object is completely described by the SC RL> package. Unfortunately, any attempt to load the object RL> (in a fresh R session) fails as below. R> library(SC) setwd("/path/to/results/") R> load("sc-results.rda") RL> Loading Tcl/Tk interface ... done Error: .onLoad failed RL> in loadNamespace() for 'SCUI', details: call: RL> optiondb_add("*Notebook.borderWidth", 2, RL> "widgetDefault") error: could not find function "tcl" RL> That call (which adds resource to Tcl resource database) RL> is made inside SCUI. Loading tcltk package removes the RL> problem. R> library(tcltk) load("sc-results.rda") ls() RL> [1] "results" RL> But I would really prefer not to need to load tcltk at RL> all just to inspect/use the object, which contains RL> nothing from SCUI anyway. Is there a way to strip the RL> unwanted UI prerequisite (tcltk and SCUI) packages from RL> the environment of the object prior/during save()? Yes, there is: > fortune("Yoda") Evelyn Hall: I would like to know how (if) I can extract some of the information from the summary of my nlme. Simon Blomberg: This is R. There is no if. Only how. -- Evelyn Hall and Simon 'Yoda' Blomberg R-help (April 2005) About the "how": I'd make use of ls.str(<the environment>) to start inspecting the objects there. To help you further, we'd need more details, e.g. such str()-like results of the things you are talking about. Martin