Monday, June 23, 2014

A Whole New R World with Chains and Pipes

I think that the recent shift in the R world to chains and pipes will become permanent.  Even if not, this style of code translates well to Javascript and other languages.  I thought a finance example exploring Fama/French factors with dplyr, magrittr, tidyr, and rCharts would help me learn and think through new workflows.



  1. Great post! I am also becoming remarkably comfortable with using pipes and chains in a remarkably short time. Have you checked out the new 'tee' operator in the latest magritte version? Using %T>% instead of %>% will execute the right hand side but return the left hand side so you can do something like z <- 1:10 %>% data.frame(x = .) %>% mutate(y = x^2) %T>% plot, which will draw the plot but still put the data.frame into z, for later use.

  2. finally got the %T>% in my rCharts workflow. thanks for the simple demo which completed the missing link in my head. I will change to the code above to demonstrate this.