separate_wider_regex: Separate a character column into multiple columns using regex...

View source: R/separate_wider_regex.R

separate_wider_regexR Documentation

Separate a character column into multiple columns using regex patterns

Description

Separate a character column into multiple columns using regex patterns

Usage

separate_wider_regex(
  .df,
  cols,
  patterns,
  ...,
  names_sep = NULL,
  names_repair = "check_unique",
  too_few = "error",
  cols_remove = TRUE
)

Arguments

.df

A data frame

cols

Columns to separate

patterns

patterns

...

These dots are for future extensions and must be empty.

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

cols_remove

Should old columns be removed

Examples

df <- tidytable(id = 1:3, x = c("m-123", "f-455", "f-123"))

df %>%
  separate_wider_regex(x, c(gender = ".", ".", unit = "\\d+"))

mtfairbanks/gdt documentation built on April 12, 2024, 6:51 p.m.