Last chance! 50% off unlimited learning
Sale ends in
There are many possible ways one could choose to nest columns inside a
data frame. nest()
creates a list of data frames containing all
the nested variables: this seems to be the most useful form in practice.
nest(data, ..., .key = data)
A data frame.
Specification of columns to nest. Use bare variable names.
Select all variables between x and z with x:z
, exclude y with
-y
. For more options, see the select documentation.
The name of the new column.
unnest
for the inverse operation.
nest_
for a version that uses regular evaluation
and is suitable for programming with.
# NOT RUN {
library(dplyr)
iris %>% nest(-Species)
chickwts %>% nest(weight)
if (require("gapminder")) {
gapminder %>%
group_by(country, continent) %>%
nest()
gapminder %>%
nest(-country, -continent)
}
# }
Run the code above in your browser using DataLab