【发布时间】:2016-04-12 11:56:17
【问题描述】:
如何从包含我在字符串向量中分配的任何值的数据框中删除所有行?我试过 grepl,但这似乎只在涉及一个词时才有效。
number <- c(1:5)
text <- c("First text","Second text","Another text here","Yet another one","Last text")
example <- as.data.frame(cbind(number,text))
number text
1 1 First text
2 2 Second text
3 3 Another text here
4 4 Yet another one
5 5 Last text
不起作用:
remove <- c("First","Yet")
example[!grepl(remove,example$text),]
期望的结果:
number text
1 2 Second text
2 3 Another text here
3 5 Last text
【问题讨论】:
-
@Jaap 这个问题与其他哪个问题重复?请链接
-
@abhishah901 看到问题的顶部.....