Pipe data from one datadr operation to another
lhs %>% rhs
a data object
a function to apply to the data
Pipes are great if you know the exact sequence of operations you would like to perform and fully understand what the intermediate data structures will look like. But often with very large or complex data sets it can be a good idea to do each step independently and examine the intermediate results. This can be better for debugging, particularly when each step takes some time to evaluate.
1 2 3 4 5 6 7 8 9
# Suppose we wish to do the following: bySpecies <- divide(iris, by = "Species") bySpeciesTransformed <- addTransform(bySpecies, function(x) mean(x$Sepal.Length)) recombine(bySpeciesTransformed, combine = combRbind) # We can do it more consely using the pipe: '%>%' divide(iris, by = "Species") %>% addTransform(function(x) mean(x$Sepal.Length)) %>% recombine(combRbind)