run_file {lumberjack} | R Documentation |
Run a file while tracking changes in data
Description
Run all code in a file. Changes in data that are tracked, (e.g. with
start_log(data)
) will be followed by the assigned loggers.
Usage
run_file(file, auto_dump = TRUE, envir = NULL)
source_file(file, auto_dump = TRUE)
Arguments
file |
|
auto_dump |
|
envir |
|
Value
The environment where the code was executed, invisibly.
Details
run\_file
runs code in a separate environment, and returns the environment with all
the variables created by the code. source\_file
acts like source
and
runs all the code in the current global workspace (.GlobalEnv
).
See Also
Other control:
%>>%()
,
dump_log()
,
get_log()
,
start_log()
,
stop_log()
Examples
# using 'dontrun'
## Not run:
# create an R file, with logging.
script <- "
library(lumberjack)
data(women)
start_log(women, logger=simple$new())
women$height <- women$height*2.54
women$weight <- women$weight*0.453592
dump_log()
"
write(script, file="myscript.R")
# run the script
lumberjack::run_file("myscript.R")
# read the logfile
read.csv("women_simple.csv")
## End(Not run)
[Package lumberjack version 1.3.1 Index]