An R6 logger that plugs into the lumberjack %L>% pipe and renders the
same console output as %>=%: row/column counts, signed deltas,
added/dropped column names, and approximate step timing.
Requires the R6 and lumberjack packages (both in Suggests).
If either is missing, the class is unavailable but the rest of logrittr
works normally.
lumberjack calls $add() after each step without providing a start time.
Elapsed time is measured as the interval between two consecutive $add()
calls. The first step always shows NA ms.
logrittr_options(), %>=%(), pipe_log
labelSet by lumberjack to the name of the tracked object.
new()Create a new logrittr_logger.
logrittr_logger$new(verbose = TRUE, src_name = NULL)dump()Called by dump_log(). Writes accumulated log to a CSV
file. If verbose = TRUE, also prints the file path.
fileCharacter. Output file path. Defaults to "simple.csv" or
"<label>_simple.csv" when a label is set.
...Additional arguments passed to write.csv().
if (FALSE) { # \dontrun{
library(lumberjack)
library(dplyr)
iris %L>%
start_log(log = logrittr_logger$new()) %L>%
as_tibble() %L>%
filter(Sepal.Length < 5) %L>%
mutate(rn = row_number()) %L>%
group_by(Species) %L>%
summarise(n = n_distinct(rn)) %L>%
dump_log(stop = TRUE)
logfile <- tempfile(fileext="r.log.csv")
iris %L>%
start_log(log = logrittr_logger$new(verbose = FALSE,
label = "A reel simple example on iris df")) %L>%
as_tibble() %L>%
filter(Sepal.Length < 5) %L>%
mutate(rn = row_number()) %L>%
group_by(Species) %L>%
summarise(n = n_distinct(rn)) %L>%
dump_log(file=logfile)
logdata <- read.csv(logfile)
head(logdata)
} # }