A function composition operator ('pipe') and extensible framework that allows for easy logging of changes in data.
install.packages('lumberjack')
To log changes in data, you need to attach a logger, and use the lumberjack
operator %>>%
.
> out <- iris %>>% # feed iris
+ start_log() %>>% # tag for logging
+ identity() %>>% # do nothing
+ head() %>>% # cut of the head
+ dump_log() # dump log
Dumped a log at /home/mark/projects/lumberjack/simple_log.csv
>
> # the processed data is here:
>
> out[1:3]
Sepal.Length Sepal.Width Petal.Length
1 5.1 3.5 1.4
2 4.9 3.0 1.4
3 4.7 3.2 1.3
4 4.6 3.1 1.5
5 5.0 3.6 1.4
6 5.4 3.9 1.7
>
> # the log is here:
> read.csv("simple_log.csv")
step time expression changed
1 1 2017-06-01 12:08:03 identity() FALSE
2 2 2017-06-01 12:08:03 head() TRUE
The start_log
function takes as its argument a logging object, which is a
Reference or a
R6
class implementing two methods: $add
and $dump
. Other than that it is
completely flexible and users can write their own loggers as desired.