nest2: Performs the same operation as 'tidyr::nest()', but allows...

Description Usage Arguments Examples

Description

See tidyr::nest() for additional documentation

Usage

1
nest2(data, ..., .key = "data")

Arguments

data

A data frame.

...

A selection of columns. If empty, all variables are selected. You can supply bare variable names, select all variables between x and z with 'x:z', exclude y with '-y'. For more options, see the dplyr::select() documentation. See also the section on selection rules for tidyr::nest().

.key

The name of the new column, as a string or symbol.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#Nest a column with a list column already present

library(tidyr)
library(dplyr)
library(tibble)

as_tibble(iris) %>%
 rowid_to_column("rowid") %>%
 nest2(starts_with("Sepal"), .key = "Sepal") %>%
 nest2(starts_with("Petal"), .key = "Petal")

#This does not work with tidyr::nest()

## Not run: 

as_tibble(iris) %>%
 rowid_to_column("rowid") %>%
 nest(starts_with("Sepal"), .key = "Sepal") %>%
 nest(starts_with("Petal"), .key = "Petal")

## End(Not run)

JakeNel28/nestyr documentation built on May 14, 2019, 7:14 p.m.