From proebuck at mdanderson.org  Tue Aug 24 18:06:54 2010
From: proebuck at mdanderson.org (Roebuck,Paul L)
Date: Tue, 24 Aug 2010 11:06:54 -0500
Subject: [Rd] save() object w/o all of the loaded environment
Message-ID: <C899584E.9BE0%proebuck@mdanderson.org>

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



[Rd] save() object w/o all of the loaded environment
Roebuck,Paul L