combine() acts like c() or unlist() but uses consistent dplyr coercion rules.

If combine() it is called with exactly one list argument, the list is simplified (similarly to unlist(recursive = FALSE)). NULL arguments are ignored. If the result is empty, logical() is returned. Use vctrs::vec_c() if you never want to unlist.

combine(...)

Arguments

...

Vectors to combine.

Details

Questioning lifecycle

See also

Examples

# combine applies the same coercion rules as bind_rows() f1 <- factor("a") f2 <- factor("b") c(f1, f2)
#> [1] 1 1
unlist(list(f1, f2))
#> [1] a b #> Levels: a b
combine(f1, f2)
#> Warning: Unequal factor levels: coercing to character
#> Warning: binding character and factor vector, coercing into character vector
#> Warning: binding character and factor vector, coercing into character vector
#> [1] "a" "b"
combine(list(f1, f2))
#> Warning: Unequal factor levels: coercing to character
#> Warning: binding character and factor vector, coercing into character vector
#> Warning: binding character and factor vector, coercing into character vector
#> [1] "a" "b"