我正在try 使用str_plit来拆分以下代码:
col |
---|
a_b_c |
c_d_e |
进入这一阶段:
col_1 | col_2 | col_3 |
---|---|---|
a | b | c |
c | d | e |
以下是代码,但我收到关于替换行不匹配的错误
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])