nplyr

nplyr: a grammar of (nested) data manipulation :bird:

https://github.com/jibarozzo/nplyr

Science Score: 26.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
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

nplyr: a grammar of (nested) data manipulation :bird:

Basic Info
Statistics
  • Stars: 122
  • Watchers: 6
  • Forks: 3
  • Open Issues: 9
  • Releases: 3
Created about 4 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  message = FALSE,
  warning = FALSE
)
```

# nplyr 



[![R-CMD-check](https://github.com/jibarozzo/nplyr/workflows/R-CMD-check/badge.svg)](https://github.com/jibarozzo/nplyr/actions)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/nplyr)](https://CRAN.R-project.org/package=nplyr)
[![](https://cranlogs.r-pkg.org/badges/grand-total/nplyr)](https://cran.r-project.org/package=nplyr)


## Overview

`{nplyr}` is a grammar of nested data manipulation that allows users to perform [dplyr](https://dplyr.tidyverse.org/)-like manipulations on data frames nested within a list-col of another data frame. Most dplyr verbs have nested equivalents in nplyr. A (non-exhaustive) list of examples:

* `nest_mutate()` is the nested equivalent of `mutate()`
* `nest_select()` is the nested equivalent of `select()`
* `nest_filter()` is the nested equivalent of `filter()`
* `nest_summarise()` is the nested equivalent of `summarise()`
* `nest_group_by()` is the nested equivalent of `group_by()`

As of version 0.2.0, nplyr also supports nested versions of some [tidyr](https://tidyr.tidyverse.org/) functions:

* `nest_drop_na()` is the nested equivalent of `drop_na()`
* `nest_extract()` is the nested equivalent of `extract()`
* `nest_fill()` is the nested equivalent of `fill()`
* `nest_replace_na()` is the nested equivalent of `replace_na()`
* `nest_separate()` is the nested equivalent of `separate()`
* `nest_unite()` is the nested equivalent of `unite()`

nplyr is largely a wrapper for dplyr. For the most up-to-date information on dplyr please visit [dplyr's website](https://dplyr.tidyverse.org). If you are new to dplyr, the best place to start is the [data transformation chapter](https://r4ds.had.co.nz/transform.html) in R for data science.

## Installation

You can install the released version of nplyr from CRAN or the development version from github with the [devtools](https://cran.r-project.org/package=devtools) or [remotes](https://cran.r-project.org/package=remotes) package:

```{r, eval=FALSE}
# install from CRAN
install.packages("nplyr")

# install from github
devtools::install_github("jibarozzo/nplyr")
```

## Usage

To get started, we'll create a nested column for the country data within each continent from the [gapminder](https://CRAN.R-project.org/package=gapminder) dataset.

```{r}
library(nplyr)

gm_nest <-
  gapminder::gapminder_unfiltered %>%
  tidyr::nest(country_data = -continent)

gm_nest
```

dplyr can perform operations on the top-level data frame, but with nplyr, we can perform operations on the nested data frames:

```{r}
gm_nest_example <-
  gm_nest %>%
  nest_filter(country_data, year == max(year)) %>%
  nest_mutate(country_data, pop_millions = pop / 1000000)

# each nested tibble is now filtered to the most recent year
gm_nest_example

# if we unnest, we can see that a new column for pop_millions has been added
gm_nest_example %>%
  slice_head(n = 1) %>%
  tidyr::unnest(country_data)
```

nplyr also supports grouped operations with `nest_group_by()`:

```{r}
gm_nest_example <-
  gm_nest %>%
  nest_group_by(country_data, year) %>%
  nest_summarise(
    country_data,
    n = n(),
    lifeExp = median(lifeExp),
    pop = median(pop),
    gdpPercap = median(gdpPercap)
  )

gm_nest_example

# unnesting shows summarised tibbles for each continent
gm_nest_example %>%
  slice(2) %>%
  tidyr::unnest(country_data)
```

More examples can be found in the package vignettes and function documentation.

## Bug reports/feature requests

If you notice a bug, want to request a new feature, or have recommendations on improving documentation, please [open an issue](https://github.com/jibarozzo/nplyr/issues) in the package repository. 

Owner

  • Name: Bolívar Aponte Rolón
  • Login: jibarozzo
  • Kind: user
  • Company: Tulane University

PhD candidate in Ecology & Evolutionary Biology at Tulane. My research focuses on foliar fungal endophytes in tropical and alpine ecosystems.

GitHub Events

Total
  • Issues event: 1
  • Watch event: 2
  • Delete event: 2
  • Push event: 10
  • Pull request event: 4
  • Create event: 2
Last Year
  • Issues event: 1
  • Watch event: 2
  • Delete event: 2
  • Push event: 10
  • Pull request event: 4
  • Create event: 2

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 1
  • Total pull requests: 2
  • Average time to close issues: over 1 year
  • Average time to close pull requests: about 11 hours
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: about 11 hours
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • markjrieke (1)
Pull Request Authors
  • jibarozzo (2)
Top Labels
Issue Labels
Pull Request Labels
bug (2) documentation (2)

Packages

  • Total packages: 1
  • Total downloads:
    • cran 663 last-month
  • Total docker downloads: 19
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
cran.r-project.org: nplyr

A Grammar of Nested Data Manipulation

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 663 Last month
  • Docker Downloads: 19
Rankings
Stargazers count: 3.8%
Forks count: 14.9%
Average: 24.0%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 35.9%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • dplyr * depends
  • assertthat * imports
  • purrr * imports
  • rlang * imports
  • stringr * suggests
  • testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/check-r-package v1 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 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