All Projects → tidyverse → Purrr

tidyverse / Purrr

Licence: other
A functional programming toolkit for R

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Purrr

J8plus
Library containing useful tools for Java 8
Stars: ✭ 23 (-97.59%)
Mutual labels:  functional-programming
Purify
Functional programming library for TypeScript - https://gigobyte.github.io/purify/
Stars: ✭ 843 (-11.54%)
Mutual labels:  functional-programming
Mori Ext
Function bind syntax wrappers for mori
Stars: ✭ 15 (-98.43%)
Mutual labels:  functional-programming
Puddles
Tiny vdom app framework. Pure Redux. No boilerplate.
Stars: ✭ 24 (-97.48%)
Mutual labels:  functional-programming
Cfl
a Compileable statically typed Functional programming Language
Stars: ✭ 7 (-99.27%)
Mutual labels:  functional-programming
Mappy
A functional programming language. Like LISP but focused around maps rather than lists.
Stars: ✭ 10 (-98.95%)
Mutual labels:  functional-programming
Txmonad
A toy xmonad
Stars: ✭ 22 (-97.69%)
Mutual labels:  functional-programming
Enum Fp
Functional Enum type / Sum type for javascript with simple pattern matching
Stars: ✭ 27 (-97.17%)
Mutual labels:  functional-programming
Blog Src
Personal blog source.
Stars: ✭ 7 (-99.27%)
Mutual labels:  functional-programming
Bugz
🐛 Composable User Agent Detection using Ramda
Stars: ✭ 15 (-98.43%)
Mutual labels:  functional-programming
Elm Cheat Sheet
An overview of Elm syntax and features
Stars: ✭ 928 (-2.62%)
Mutual labels:  functional-programming
D4s
Dynamo DB Database Done Scala-way
Stars: ✭ 27 (-97.17%)
Mutual labels:  functional-programming
Revery Playground
Live, interactive playground for Revery examples
Stars: ✭ 14 (-98.53%)
Mutual labels:  functional-programming
Union Js
🏷️ Tagged unions for vanilla JavaScript!
Stars: ✭ 24 (-97.48%)
Mutual labels:  functional-programming
Opal
Simple and powerful programming language with type inference
Stars: ✭ 20 (-97.9%)
Mutual labels:  functional-programming
Proppy
Functional props composition for UI components (React.js & Vue.js)
Stars: ✭ 921 (-3.36%)
Mutual labels:  functional-programming
Goderive
Code Generation for Functional Programming, Concurrency and Generics in Golang
Stars: ✭ 848 (-11.02%)
Mutual labels:  functional-programming
Immutable Tuple
Immutable finite list objects with constant-time equality testing (===) and no memory leaks.
Stars: ✭ 29 (-96.96%)
Mutual labels:  functional-programming
Facsimile
Facsimile Simulation Library
Stars: ✭ 20 (-97.9%)
Mutual labels:  functional-programming
Funktionale
Functional constructs for Kotlin
Stars: ✭ 879 (-7.76%)
Mutual labels:  functional-programming

purrr

CRAN_Status_Badge R build status Codecov test coverage

Overview

purrr enhances R’s functional programming (FP) toolkit by providing a complete and consistent set of tools for working with functions and vectors. If you’ve never heard of FP before, the best place to start is the family of map() functions which allow you to replace many for loops with code that is both more succinct and easier to read. The best place to learn about the map() functions is the iteration chapter in R for data science.

Installation

# The easiest way to get purrr is to install the whole tidyverse:
install.packages("tidyverse")

# Alternatively, install just purrr:
install.packages("purrr")

# Or the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/purrr")

Cheatsheet

Usage

The following example uses purrr to solve a fairly realistic problem: split a data frame into pieces, fit a model to each piece, compute the summary, then extract the R2.

library(purrr)

mtcars %>%
  split(.$cyl) %>% # from base R
  map(~ lm(mpg ~ wt, data = .)) %>%
  map(summary) %>%
  map_dbl("r.squared")
#>         4         6         8 
#> 0.5086326 0.4645102 0.4229655

This example illustrates some of the advantages of purrr functions over the equivalents in base R:

  • The first argument is always the data, so purrr works naturally with the pipe.

  • All purrr functions are type-stable. They always return the advertised output type (map() returns lists; map_dbl() returns double vectors), or they throw an error.

  • All map() functions either accept function, formulas (used for succinctly generating anonymous functions), a character vector (used to extract components by name), or a numeric vector (used to extract by position).


Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].