Given either a regular expression or a vector of character positions,
separate_col()
turns a single character column into multiple columns.
Arguments
- .data
A data frame
- col
Column name
- into
Names of new variables to create as character vector
- sep
The separator between columns. By default, a regular expression that matches any sequence of non-alphanumeric values.
Examples
library(pliman)
df <- data.frame(x = paste0("TRAT_", 1:5),
y = 1:5)
df
#> x y
#> 1 TRAT_1 1
#> 2 TRAT_2 2
#> 3 TRAT_3 3
#> 4 TRAT_4 4
#> 5 TRAT_5 5
separate_col(df, x, into = c("TRAT", "REP"))