separate_dt {tidyfst} | R 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 |
See Also
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"))
[Package tidyfst version 1.7.9 Index]