50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

lumberjack (version 1.3.1)

run_file: 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)

Value

The environment where the code was executed, invisibly.

Arguments

file

[character] file to run.

auto_dump

[logical] Toggle automatically dump all remaining logs after executing file.

envir

[environment] to run the code in. By default a new environment will be created with .GlobalEnv as parent.

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

Run this code
# 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