logrx-package

library(logrx)

The purpose of the logrx package is to generate a log upon execution of an R script which enables traceability and reproducibility of the executed code.

Log attributes

The following attributes are recorded in the log:

Generating a log

The log can be generated according in two ways:

axecute()

axecute() enables the command line submission of a program. A log is set-up around the program, and its code is run safely and loudly (using safely() from the purrr package).

axecute("my_script.R")

log_*() functions

Use the log_*() functions:

log_config("my_script.R")
run_safely_loudly("my_script.R")
log_write()

Scripting with logrx

While logrx is built around creating a log for a program it can just as easily be used when running an entire set of programs. The axecute() function has been built with both single file execution and scripted file execution in mind. With the use of simple functions such as lapply() scripting is easy. Below is some sample code of how lapply() can be used with axecute().

lapply(c("file.R", "otherfile.R"), axecute)

If your scripting needs to work on the contents of a directory instead of a pre-defined list, functions such as list.files can be used to obtain a list of files to use. Below is an example of how this can be applied in practice by getting all files ending in ‘.R’ in the current working directory using a regular expression, and then using lapply() to run the files using axecute().

r_script_list <- list.files(path = ".", pattern = "\\.R$")
lapply(r_script_list, axecute)