nest_unite {nplyr} | R Documentation |
Unite multiple columns into one in a column of nested data frames
Description
nest_unite()
is used to combine multiple columns into one in a column of
nested data frames.
Usage
nest_unite(
.data,
.nest_data,
col,
...,
sep = "_",
remove = TRUE,
na.rm = FALSE
)
Arguments
.data |
A data frame, data frame extension (e.g., a tibble), or a lazy data frame (e.g., from dbplyr or dtplyr). |
.nest_data |
A list-column containing data frames |
col |
The name of the new column, as a string or symbol. This argument is passed by expression and supports
quasiquotation (you can unquote strings
and symbols). The name is captured from the expression with
|
... |
Columns to unite. |
sep |
Separator to use between values. |
remove |
If |
na.rm |
If |
Details
nest_unite()
is a wrapper for tidyr::unite()
and maintains the functionality
of unite()
within each nested data frame. For more information on unite()
please refer to the documentation in 'tidyr'.
Value
An object of the same type as .data
. Each object in the column .nest_data
will have a new column created as a combination of existing columns.
See Also
Other tidyr verbs:
nest_drop_na()
,
nest_extract()
,
nest_fill()
,
nest_replace_na()
,
nest_separate()
Examples
set.seed(123)
gm <- gapminder::gapminder
gm_nest <- gm %>% tidyr::nest(country_data = -continent)
gm_nest %>%
nest_unite(.nest_data = country_data,
col = comb,
year,
pop)