purrr

A functional programming toolkit for R

https://github.com/tidyverse/purrr

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    5 of 111 committers (4.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.5%) to scientific vocabulary

Keywords

functional-programming r

Keywords from Contributors

tidy-data data-manipulation grammar visualisation parsing csv fwf documentation-tool rmarkdown package-creation
Last synced: 6 months ago · JSON representation

Repository

A functional programming toolkit for R

Basic Info
Statistics
  • Stars: 1,337
  • Watchers: 63
  • Forks: 284
  • Open Issues: 30
  • Releases: 18
Topics
functional-programming r
Created about 11 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Codeowners Support

README.Rmd

---
output: github_document
---



```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
```

# purrr 


[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/purrr)](https://cran.r-project.org/package=purrr)
[![Codecov test coverage](https://codecov.io/gh/tidyverse/purrr/branch/master/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/purrr?branch=master)
[![R-CMD-check](https://github.com/tidyverse/purrr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidyverse/purrr/actions/workflows/R-CMD-check.yaml)


## 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](https://r4ds.hadley.nz/iteration) in R for Data Science.

## Installation

```{r, eval = FALSE}
# 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("pak")
pak::pak("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 R^2^.

```{r}
library(purrr)

mtcars |> 
  split(mtcars$cyl) |>  # from base R
  map(\(df) lm(mpg ~ wt, data = df)) |> 
  map(summary) |>
  map_dbl("r.squared")
```

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 accept functions (named, anonymous, and lambda), 
  character vector (used to extract components by name), or numeric vectors 
  (used to extract by position).

There are two less obvious advantages:

* All `map()` functions have `.progress` argument so that you can easily track
  the progress of long running jobs.

* All `map()` functions work with `in_parallel()` to easily spread computation 
  across multiple cores on your computer, or multiple machines over the network.

Owner

  • Name: tidyverse
  • Login: tidyverse
  • Kind: organization

The tidyverse is a collection of R packages that share common principles and are designed to work together seamlessly

GitHub Events

Total
  • Create event: 5
  • Release event: 2
  • Issues event: 45
  • Watch event: 74
  • Delete event: 4
  • Member event: 1
  • Issue comment event: 68
  • Push event: 43
  • Pull request review event: 78
  • Pull request review comment event: 99
  • Pull request event: 43
  • Fork event: 14
Last Year
  • Create event: 5
  • Release event: 2
  • Issues event: 45
  • Watch event: 74
  • Delete event: 4
  • Member event: 1
  • Issue comment event: 68
  • Push event: 43
  • Pull request review event: 78
  • Pull request review comment event: 99
  • Pull request event: 43
  • Fork event: 14

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 1,216
  • Total Committers: 111
  • Avg Commits per committer: 10.955
  • Development Distribution Score (DDS): 0.576
Past Year
  • Commits: 45
  • Committers: 19
  • Avg Commits per committer: 2.368
  • Development Distribution Score (DDS): 0.6
Top Committers
Name Email Commits
hadley h****m@g****m 515
Lionel Henry l****y@g****m 511
Mara Averick m****k@g****m 11
Davis Vaughan d****s@r****m 11
Charlie Gao 5****o 9
Jennifer (Jenny) Bryan j****n@g****m 9
yutannihilation y****i@g****m 8
Kirill Müller k****r@m****g 6
Philipp A f****p@w****e 5
Dan Jordan d****j@g****m 4
michaelquinn32 m****n@a****u 4
coolbutuseless c****s 3
Colin Fay c****t@c****e 3
Christophe Dervieux c****x@g****m 3
Maximilian Girlich m****h@m****m 2
Jim Hester j****r@g****m 2
James Lamb j****0@g****m 2
James Laird-Smith j****h@g****m 2
Ian Lyttle i****e 2
Mikko Marttila m****t@m****m 2
Will Beasley w****y@h****m 2
William Lai 4****2 2
burchill b****l 2
Jeffrey Arnold j****d@g****m 2
jennybc j****y@s****a 2
thoened t****d@I****l 2
Salim B s****m@p****e 2
Artem Klevtsov a****v@g****m 2
Daniel Barnett 1****t 2
Gábor Csárdi c****r@g****m 2
and 81 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 138
  • Total pull requests: 143
  • Average time to close issues: 3 months
  • Average time to close pull requests: 28 days
  • Total issue authors: 83
  • Total pull request authors: 38
  • Average comments per issue: 1.8
  • Average comments per pull request: 0.76
  • Merged pull requests: 108
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 32
  • Pull requests: 47
  • Average time to close issues: 20 days
  • Average time to close pull requests: 11 days
  • Issue authors: 24
  • Pull request authors: 9
  • Average comments per issue: 0.56
  • Average comments per pull request: 0.4
  • Merged pull requests: 28
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hadley (23)
  • DanChaltiel (10)
  • DavisVaughan (6)
  • mmuurr (4)
  • mgirlich (4)
  • ggrothendieck (3)
  • werkstattcodes (3)
  • shikokuchuo (3)
  • mlane3 (2)
  • brunomioto (2)
  • tyner (2)
  • h-a-graham (2)
  • totvi (2)
  • lmiratrix (2)
  • mattwarkentin (1)
Pull Request Authors
  • hadley (43)
  • shikokuchuo (22)
  • DavisVaughan (8)
  • matthewjnield (6)
  • jayhesselberth (4)
  • batpigandme (4)
  • gaborcsardi (3)
  • salim-b (3)
  • SoyAndrea (2)
  • ccani007 (2)
  • maike2011 (2)
  • KimLopezGuell (2)
  • krlmlr (2)
  • catalamarti (2)
  • MichaelChirico (2)
Top Labels
Issue Labels
tidy-dev-day :nerd_face: (14) feature (11) bug (7) map :world_map: (6) documentation (6) upkeep (3) reprex (3) flatten :earth_americas: (2) performance (2) modify :hammer_and_wrench: (1) lifecycle :butterfly: (1) adverb :books: (1) list 🧦 (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 1,340,116 last-month
  • Total docker downloads: 156,037,277
  • Total dependent packages: 2,107
    (may contain duplicates)
  • Total dependent repositories: 7,904
    (may contain duplicates)
  • Total versions: 46
  • Total maintainers: 1
cran.r-project.org: purrr

Functional Programming Tools

  • Versions: 19
  • Dependent Packages: 1,900
  • Dependent Repositories: 7,824
  • Downloads: 1,340,116 Last month
  • Docker Downloads: 156,037,277
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.1%
Downloads: 0.1%
Stargazers count: 0.2%
Forks count: 0.2%
Average: 3.0%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: r-purrr
  • Versions: 9
  • Dependent Packages: 207
  • Dependent Repositories: 80
Rankings
Dependent packages count: 0.3%
Dependent repos count: 3.9%
Average: 6.9%
Forks count: 11.6%
Stargazers count: 11.9%
Last synced: 6 months ago
proxy.golang.org: github.com/tidyverse/purrr
  • Versions: 18
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 9.0%
Average: 9.6%
Dependent repos count: 10.2%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.2.3 depends
  • cli * imports
  • lifecycle >= 1.0.1.9001 imports
  • magrittr >= 1.5.0 imports
  • rlang >= 0.4.10 imports
  • vctrs >= 0.3.2 imports
  • covr * suggests
  • dplyr >= 0.7.8 suggests
  • knitr * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests
  • tibble * suggests
  • tidyselect * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action 4.1.4 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/pr-fetch v2 composite
  • r-lib/actions/pr-push v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite