flatten

0th

Percentile

Flatten a list of lists into a simple vector.

These functions remove a level hierarchy from a list. They are similar to unlist, only ever remove a single layer of hierarchy, and are type-stable so you always know what the type of the output is.

Usage
flatten(.x)

flatten_lgl(.x)

flatten_int(.x)

flatten_dbl(.x)

flatten_chr(.x)

flatten_df(.x, .id = NULL)

Arguments
.x

A list of flatten. The contents of the list can be anything for flatten (as a list is returned), but the contents must match the type for the other functions.

.id

If not NULL a variable with this name will be created giving either the name or the index of the data frame.

Value

flatten() returns a list, flatten_lgl a logical vector, flatten_int an integer vector, flatten_dbl a double vector, and flatten_chr a character vector.

Aliases
  • flatten
  • flatten_lgl
  • flatten_int
  • flatten_dbl
  • flatten_chr
  • flatten_df
Examples
# NOT RUN {
x <- rerun(2, sample(4))
x
x %>% flatten()
x %>% flatten_int()

# You can use flatten in conjunction with map
x %>% map(1L) %>% flatten_int()
# But it's more efficient to use the typed map instead.
x %>% map_int(1L)
# }
Documentation reproduced from package purrr, version 0.2.2.2, License: GPL-3 | file LICENSE

Community examples

Looks like there are no examples yet.