Pretty sure @nick covered all of this (and more), but, since I wrote it up anyway…
unlist()
, flatten()
, and squash()
unlist()
- base R generic that will take a list,
x
, and produce a vector with all
atomic components of x - output determined by highest type component in hierarchy
NULL < raw < logical < integer < double < complex < character < list < expression
flatten()
- both
rlang::flatten()
andrlang::squash()
can turn a list of lists into
a list or, simpler, type-stable vector -
flatten()
only removes one level of hierarchy from a list -
purrr::flatten()
applies as described above, but takes the argument.x
- the unsuffixed
flatten()
will return a list regardless of contents of input
list, but contents must match type forflatten_*()
funtions
squash()
- removes all levels of hierarchy from list of lists, and otherwise
follows the same conventions asrlang::flatten()
, with type-stable output
returned for suffixed functions
tidyr::unnest()
unnest()
-
tidyr::unnest()
takes a list column, and makes each element into its own row - list column contents can be atomic vectors, or data frames,
but each row must have the same number of entries