unnest {tidyseurat} | R Documentation |
Unnest a list-column of data frames into rows and columns
Description
Unnest expands a list-column containing data frames into rows and columns.
Usage
## S3 method for class 'tidyseurat_nested'
unnest(
data,
cols,
...,
keep_empty = FALSE,
ptype = NULL,
names_sep = NULL,
names_repair = "check_unique",
.drop,
.id,
.sep,
.preserve
)
unnest_seurat(
data,
cols,
...,
keep_empty = FALSE,
ptype = NULL,
names_sep = NULL,
names_repair = "check_unique",
.drop,
.id,
.sep,
.preserve
)
Arguments
data |
A data frame. |
cols |
< When selecting multiple columns, values from the same row will be recycled to their common size. |
... |
:
previously you could write |
keep_empty |
By default, you get one row of output for each element
of the list that you are unchopping/unnesting. This means that if there's a
size-0 element (like |
ptype |
Optionally, a named list of column name-prototype pairs to
coerce |
names_sep |
If |
names_repair |
Used to check that output data frame has valid names. Must be one of the following options:
See |
.drop , .preserve |
:
all list-columns are now preserved; If there are any that you
don't want in the output use |
.id |
:
convert |
.sep |
Value
'tidyseurat'
New syntax
tidyr 1.0.0 introduced a new syntax for nest()
and unnest()
that's
designed to be more similar to other functions. Converting to the new syntax
should be straightforward (guided by the message you'll receive) but if
you just need to run an old analysis, you can easily revert to the previous
behaviour using nest_legacy()
and unnest_legacy()
as follows:
library(tidyr) nest <- nest_legacy unnest <- unnest_legacy
See Also
Other rectangling:
hoist()
,
unnest_longer()
,
unnest_wider()
Examples
data(pbmc_small)
pbmc_small |>
nest(data=-groups) |>
unnest(data)