Coder Social home page Coder Social logo

flogr's Introduction

flogr: A lightweight, functional, logging tool for use in R-based data-analysis pipelines

You're analysing data in R: this involves piping together a bunch of functions and writing a report. At the end, you've got access to the input-to and the output-from that pipeline of functions. So, you can't readily peak at what the data looked like during the intermediate processing steps anymore. To add those intermediate results to your report you could either

  1. add side-effects to the functions in your pipeline, eg to print/plot results out during processing;
  2. use the %T>% pass-through pipe to print-out intermediate results without modifying your functions;
  3. save intermediate results to variables and print/plot them out within your report
  4. use flog

If your pipeline looks like this:

result <- input %>% f1 %>% f2 %>% f3

Then you can rewrite the same pipeline using flogr as follows:

result <- input %>% flog(modifiers = c(f1, f2, f3), null_logger) %>% get_dataset

but this just gives you the same information.

Suppose you wanted to make a graph based on f1(input), but otherwise discard the results of f1(input)

result_tuple <- input %>%
  flog(modifier = f1,
       logger = function(post) ggplot(post, aes(x = x, y = y)) + geom_line()
       ) %>%
  flog(c(f2, f3), null_logger)
  
result2 <- get_dataset(result_tuple) # identical to `result` above

Then you could print out that graph after the pipeline has ran, rather than printing it as a side-effect:

# print out the graph
get_logdata(result_tuple)[[1]]

That is, flog just provides a wrapper around functions, where you can save intermediate results / figures and access them later, without having to save those things as a side-effect.

TODO: flog_filter_df

flogr's People

Contributors

russhyde avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.