From 4911b9f05e19921c9b963404d142b230d7004f5a Mon Sep 17 00:00:00 2001 From: "Roger D. Peng [audrey]" Date: Mon, 30 Apr 2007 11:47:44 -0400 Subject: [PATCH] comments --- R/SweaveCache.R | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/R/SweaveCache.R b/R/SweaveCache.R index 4c02704..b2cefee 100644 --- a/R/SweaveCache.R +++ b/R/SweaveCache.R @@ -62,12 +62,18 @@ copy2env <- function(keys, fromEnv, toEnv) { } ## Check for new symbols in 'e2' that are not in 'e1'; doesn't check -## for modified symbols +## for modified symbols. +## If 'source()' was used, there may be new symbols in the global +## environment, unless 'source(local = TRUE)' was used. Also applies +## for 'set.seed()'. + checkNewSymbols <- function(e1, e2) { if(identical(e1, e2)) return(character(0)) specials <- c(".Random.seed") + + ## Don't check for names beginning with '.' for now sym1 <- ls(e1) sym2 <- ls(e2) newsym <- setdiff(sym2, sym1) @@ -89,16 +95,13 @@ evalAndDumpToDB <- function(db, expr, exprDigest) { env <- new.env(parent = globalenv()) global1 <- globalenv() - ## Evaluate the expression eval(expr, env) - ## If 'source()' was used, there may be new symbols in the - ## global environment, unless 'source(local = TRUE)' was used. - ## Also applies for 'set.seed()'. - global2 <- globalenv() - new.global <- checkNewSymbols(global1, global2) + ## Functions like 'source' and 'set.seed' alter the global + ## environment, so check after evaluation + new.global <- checkNewSymbols(global1, global2) copy2env(new.global, globalenv(), env) ## Get newly assigned object names -- 2.11.4.GIT