使用R,当同一行的“ Column2”的内容中包含一个单词时,是否有正则表达式让“ Column1”中的“单元格”更新?
例如#如果我希望在其中任何位置包含“时间”的单元格将矩阵“ Column1”更新为“ 10”,如下所示
Column1 Column2
10 that is the time
10 what time is the match
0 where is the car?
目前,我可以使它适用于非正则表达式(仅当使用以下命令时,确切的单元格内容是“时间”时才可以使用);
ds1$test[ds1$Column2 %in% "time"] <- 10
提前致谢。
我们可以用 grep
df1$Column1[grep("time", df1$Column2)] <- 10
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句