
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.
run_file(file, auto_dump = TRUE, envir = NULL)source_file(file, auto_dump = TRUE)
The environment where the code was executed, invisibly.
[character]
file to run.
[logical]
Toggle automatically dump all remaining logs
after executing file
.
[environment]
to run the code in. By default a new environment will be created
with .GlobalEnv
as parent.
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
).
Other control:
%>>%()
,
dump_log()
,
get_log()
,
start_log()
,
stop_log()
# using 'dontrun'
if (FALSE) {
# 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")
}
Run the code above in your browser using DataLab