inst/tinytest/test_expressionlogger.R

library(lumberjack)
## expression logger


tmpfile <- tempfile()
logger <- expression_logger$new(
    mh      = mean(height)
  , mw      = mean(weight)
  , verbose = FALSE
)

women %L>%
  start_log(logger) %L>%
  identity() %L>%
  {.$height <- 2*.$height; .} %L>%
  dump_log(file=tmpfile)
lg <- read.csv(tmpfile)
expect_equal(lg$mh[1], mean(women$height))
expect_equal(lg$mw[1], mean(women$weight))
expect_equal(lg$mh[2], mean(2*women$height))
expect_equal(lg$mw[2], mean(women$weight))

expect_true("label" %in% ls(logger))

expect_true(all(is.na(lg$srcref)))

Try the lumberjack package in your browser

Any scripts or data that you put into this service are public.

lumberjack documentation built on March 31, 2023, 7:56 p.m.