storeEval: Evaluate R code and time, store results or monitor changes to...

View source: R/storeEval2.R

storeEvalR Documentation

Evaluate R code and time, store results or monitor changes to .Random.seed for each top-level expression

Description

These functions are similar to source but evaluate each top-level expression and do something for each of these.

timeEval times how long each expression took to complete.

storeEval saves the result of each top-level as an intermediate result that we can then compare as we change the code. This helps us identify when and where changes give different results.

seedChangeEval checks whether the value of .Random.seed changed during the evaluation of each top-level expression. Again, this can help us debug changes to the code.

Usage

storeEval(code, envir = globalenv(), verbose = TRUE, store = new.env(), outVars = getOutputVariables(code), all = TRUE, ...)

Arguments

code

the R code, as a file name or the text or the parsed code

envir

the environment in which to evaluate each top-level expression.

verbose

a logical value controlling whether each expression is displayed before it is evaluated.

store

the environment object in which to store/assign the intermediate results.

outVars

the names of all the variables for which we want intermediate results

all

a logical value that controls whether we also add the final versions of each variable to store, or just the intermediate variables. The final versions are available in envir.

...

ignore at present

Value

storeEval returns the store environment object containing the intermediate results.

timeEval returns a list of the results from calling system.time when evaluating each top-level expression.

seedChangeEval returns a list with the code for top-level expressions grouped into sub-lists according to whether they were evaluated with the same value for .Random.seed.

Author(s)

Duncan Temple Lang

See Also

eval new.env

Examples

f = system.file("sampleCode", "storeEvalEg.R", package = "CallCounter")
im = storeEval(f)


f = system.file("sampleCode", "timeEvalEg.R", package = "CallCounter")
tms = timeEval(f)
sapply(tms, `[`, 3)


f = system.file("sampleCode", "stochastic.R", package = "CallCounter")
iseed = seedChangeEval(f)

duncantl/CallCounter documentation built on Nov. 23, 2023, 3:38 p.m.