From maechler at stat.math.ethz.ch  Wed Aug 25 09:42:20 2010
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed, 25 Aug 2010 09:42:20 +0200
Subject: [Rd] save() object w/o all of the loaded environment
In-Reply-To: <C899584E.9BE0%proebuck@mdanderson.org>
References: <C899584E.9BE0%proebuck@mdanderson.org>
Message-ID: <19572.51548.264299.417078@lynne.math.ethz.ch>

>>>>> "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



[Rd] save() object w/o all of the loaded environment
Martin Maechler