From D.Strbenac at garvan.org.au  Wed Oct 20 08:00:15 2010
From: D.Strbenac at garvan.org.au (Dario Strbenac)
Date: Wed, 20 Oct 2010 16:00:15 +1000 (EST)
Subject: [Rd] Loading Cached Weaver Objects
In-Reply-To: <4CBE7AA6.1010505@fhcrc.org>
References: <20101020133311.BJK44386@gimr.garvan.unsw.edu.au>
	<4CBE7AA6.1010505@fhcrc.org>
Message-ID: <20101020160015.BJK48730@gimr.garvan.unsw.edu.au>

Thanks. I was able to get them out via 

cacheEnv[["varName"]]

- Dario.

---- Original message ----
>Date: Tue, 19 Oct 2010 22:14:14 -0700
>From: Martin Morgan <mtmorgan at fhcrc.org>  
>Subject: Re: [Rd] Loading Cached Weaver Objects  
>To: D.Strbenac at garvan.org.au
>Cc: r-devel at r-project.org, seth at userprimary.net
>
>On 10/19/2010 08:33 PM, Dario Strbenac wrote:
>> Hello,
>> 
>> I'm looking for a way to extract objects from what gets created when I Sweave with driver = weaver(). I found where the .Rdata objects are, but when I load one into R, I don't see anything that looks like the objects that were created in that code chunk.
>> 
>>> load("/home/darstr/r_env_cache/2.11.0/AbsMeth_5/ac047940aaa9cf1a1ec09f1628b13381.RData")
>>> ls()
>> [1] "cacheEnv" "DEPS"     "SESSION"
>> 
>> What can I try next ?
>
>Hi Dario
>
>Probably useful to ask the maintainer
>packageDescription('weaver')$Maintainer. But from looking at the package
>code I see
>
>eval_and_cache <- function(sexpr, deps, cacheEnv, cachefile, quiet) {
>    if (!quiet)
>      cat("  COMPUTING... ", file=stderr())
>    log_debug("computing...")
>    ## We want to pick up inherited stuff during the eval.  So no
>    ## parent=emptyenv().
>    eval(sexpr, envir=cacheEnv)
>    DEPS <- deps
>    SESSION <- sessionInfo()
>    save(cacheEnv, DEPS, SESSION, file=cachefile)
>    if (!quiet)
>      cat("done.\n", file=stderr())
>}
>
>
>load_from_cache_env <- function(fromEnv, toEnv, hash, sym2hash, updated) {
>    ## The 'updated' arg is a logical flag.  TRUE indicates that
>    ## syms in fromEnv were retrieved from cache but had to be
>    ## recomputed because of a dependency mismatch.  This is allows
>    ## us to detect second order dependency mismatch where the
>    ## expression doesn't change, but we've recomputed.
>    syms <- ls(fromEnv)
>    for (sym in syms) {
>        assign(sym, fromEnv[[sym]], envir=toEnv)
>        assign(sym, list(hash=hash, updated=updated), envir=sym2hash)
>    }
>}
>
>so would guess that 'cacheEnv' is a environment that contains the result
>of evaluating the code in the chunk.
>
>Hope that helps,
>
>Martin
>
>> 
>> --------------------------------------
>> Dario Strbenac
>> Research Assistant
>> Cancer Epigenetics
>> Garvan Institute of Medical Research
>> Darlinghurst NSW 2010
>> Australia
>> 
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>-- 
>Computational Biology
>Fred Hutchinson Cancer Research Center
>1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109
>
>Location: M1-B861
>Telephone: 206 667-2793



[Rd] Loading Cached Weaver Objects
Dario Strbenac