separate_dt: Separate a character column into two columns using a regular...

View source: R/separate.R

separate_dtR Documentation

Separate a character column into two columns using a regular expression separator

Description

Given either regular expression, separate_dt() turns a single character column into two columns.

Usage

separate_dt(
  .data,
  separated_colname,
  into,
  sep = "[^[:alnum:]]+",
  remove = TRUE
)

Arguments

.data

A data frame.

separated_colname

Column to be separated, can be a character or alias.

into

Character vector of length 2.

sep

Separator between columns.

remove

If TRUE, remove input column from output data frame.

See Also

separate, unite_dt

Examples

df <- data.frame(x = c(NA, "a.b", "a.d", "b.c"))
df %>% separate_dt(x, c("A", "B"))
# equals to
df %>% separate_dt("x", c("A", "B"))

# If you just want the second variable:
df %>% separate_dt(x,into = c(NA,"B"))

tidyfst documentation built on Sept. 16, 2024, 9:06 a.m.