【发布时间】:2021-05-11 15:22:09
【问题描述】:
我有一个数据框,其中一列包含字符串。我想拆分这些字符串,用点分隔,并始终保留第一部分。
这将是我的数据框:
State
1 This is my string. I do not want this
2 This is other string. I do not want this either
我想得到这个:
State
1 This is my string
2 This is other string
我试过了,但现在可以了:
df = df >%> dplyr::mutate(State= str_split(State,".")[1])
【问题讨论】:
标签: r string dataframe strsplit