i'm trying to use str_split to split this:
| col |
|---|
| a_b_c |
| c_d_e |
into this:
| col_1 | col_2 | col_3 |
|---|---|---|
| a | b | c |
| c | d | e |
here's the code but i'm getting an error on the replacement rows not matching
df %>%
dplyr::mutate(
col_1 = stringr::str_split(
string = col,
pattern = "_",
simplify = T)[,1],
col_2 = stringr::str_split(
string = col,
pattern = "_",
simplify = T)[,2],
col_3 = stringr::str_split(
string = col,
pattern = "_",
simplify = T)[,3])