separate_wider_delim: Separate a character column into multiple columns

View source: R/separate_wider_delim.R

separate_wider_delimR Documentation

Separate a character column into multiple columns

Description

Separates a single column into multiple columns

Usage

separate_wider_delim(
  .df,
  cols,
  delim,
  ...,
  names = NULL,
  names_sep = NULL,
  names_repair = "check_unique",
  too_few = c("align_start", "error"),
  too_many = c("drop", "error"),
  cols_remove = TRUE
)

Arguments

.df

A data frame

cols

Columns to separate

delim

Delimiter to separate on

...

These dots are for future extensions and must be empty.

names

New column names to separate into

names_sep

Names separator

names_repair

Treatment of duplicate names. See ?vctrs::vec_as_names for options/details.

too_few

What to do when too few column names are supplied

too_many

What to do when too many column names are supplied

cols_remove

Should old columns be removed

Examples

df <- tidytable(x = c("a", "a_b", "a_b", NA))

df %>%
  separate_wider_delim(x, delim = "_", names = c("left", "right"))

df %>%
  separate_wider_delim(x, delim = "_", names_sep = "")

tidytable documentation built on Sept. 11, 2024, 8:05 p.m.