我还需要Count> 0的行。我可以在一个单独的步骤中完成,但我很好奇我是否可以一步完成这两个条件。
我想删除这2条记录?和_来自我的结果集。
Type = c("alpha","bravo","charlie","?","_", "delta")
Count = c(1,2,3,4,5,0)
Desc = c("aaa","bbb","ccc","ddd","ccc", "ddd")
df = data.frame(Desc, Type,Count) # df is a data frame
df[df$Type %in% [a:z],] ## this doesn't work
答案 0 :(得分:1)
你可以尝试
df[grep('[A-Za-z]+', df$Type),]
或者
df[grep('^[^[:punct:]]+$', df$Type),]