Functional programming tools for R
open sourceMITfree
purrr is the tidyverse's package for functional programming in R: a complete and consistent set of tools for working with functions and vectors. Its family of map() functions replaces many for loops with shorter code that's easier to read, mapping a function over a list or vector and returning a list or a vector of a chosen type, with variants for two inputs, many inputs and side effects. It's installed with the tidyverse or on its own from CRAN.
Problems it solves
- replace for loops in my R code with something shorter and easier to read
- apply a function to every element of a list in R and get a vector back
- fit a model to each group of a data frame in R
Features
- map() family over lists and vectors
- typed results: map_chr, map_dbl, map_lgl
- map2 and pmap for several inputs
- walk() for side effects
- part of the tidyverse
