【发布时间】:2023-01-27 14:12:43
【问题描述】:
我有一个包含文本列的数据集,其中包含文本和一个以 sa 开头的术语,后面有两个 following digits。数据快照如下:
df_new <- data.frame(
given_info=c('SA12 is given','he has his sa12',
'she will get Sa15','why not having an sa31',
'his SA23 is missing', 'sa12 is given'))
df_new %>% select(given_info)
given_info
1 SA12 is given
2 he has his sa12
3 she will get Sa15
4 why not having an sa31
5 his SA23 is missing
6 sa12 is given
我需要用术语 document 替换任何带有 sa with the two digits 的术语。因此,感兴趣的结果是:
given_info
1 document is given
2 he has his document
3 she will get document
4 why not having an document
5 his document is missing
6 document is given
非常感谢您的提前帮助!
【问题讨论】:
标签: regex dplyr text rstudio data-cleaning