Delete rows containing specific strings in R

前端 未结 6 1599
暖寄归人
暖寄归人 2020-11-27 11:34

I would like to exclude lines containing a string \"REVERSE\", but my lines do not match exactly with the word, just contain it.

My input data frame:



        
6条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 12:05

    Actually I would use:

    df[ grep("REVERSE", df$Name, invert = TRUE) , ]
    

    This will avoid deleting all of the records if the desired search word is not contained in any of the rows.

提交回复
热议问题