R/separate_wider_delim.R
separate_wider_delim.Rd
Separates a single column into multiple columns
A data frame
Columns to separate
Delimiter to separate on
These dots are for future extensions and must be empty.
New column names to separate into
Names separator
Treatment of duplicate names. See ?vctrs::vec_as_names
for options/details.
What to do when too few column names are supplied
What to do when too many column names are supplied
Should old columns be removed
df <- tidytable(x = c("a", "a_b", "a_b", NA))
df %>%
separate_wider_delim(x, delim = "_", names = c("left", "right"))
#> # A tidytable: 4 × 2
#> left right
#> <chr> <chr>
#> 1 a NA
#> 2 a b
#> 3 a b
#> 4 NA NA
df %>%
separate_wider_delim(x, delim = "_", names_sep = "")
#> # A tidytable: 4 × 2
#> x1 x2
#> <chr> <chr>
#> 1 a NA
#> 2 a b
#> 3 a b
#> 4 NA NA