separate | R Documentation |
Given either regular expression,
separate()
turns a single character column into two columns.
Analogous to tidyr::separate
, but only split into two columns only.
separate(.data, separated_colname, into, sep = "[^[:alnum:]]+", remove = TRUE)
.data |
A data frame. |
separated_colname |
Column name, string only. |
into |
Character vector of length 2. |
sep |
Separator between columns. |
remove |
If |
A data.table
separate
, unite_dt
df <- data.table(x = c(NA, "a.b", "a.d", "b.c"))
df %>% separate(x, c("A", "B"))
# equals to
df <- data.table(x = c(NA, "a.b", "a.d", "b.c"))
df %>% separate("x", c("A", "B"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.