Using grep in R to delete rows from a data.frame

后端 未结 4 1012
北荒
北荒 2020-12-30 07:34

I have a dataframe such as this one:

    d <- data.frame(cbind(x=1, y=1:10,    z=c(\"apple\",\"pear\",\"banana\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 08:14

    For completeness, since R 3.3.0, grep and friends come with an invert argument:

    new_d <- d[grep("K", d$z, invert = TRUE)]
    

提交回复
热议问题