本文介绍了获取不包含列的给定值的子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为 data
的表:
I have a table called data
:
A 22
B 333
C Not Av.
D Not Av.
我怎样才能得到一个子集,其中包含Not Av."的所有行.被排除在外?值得一提的是,我有要检查的列的索引(在本例中为 colnum
= 2),但我没有它的名称.
How can I get a subset, from which all rows containing "Not Av." are excluded? It is important to mention that I have the index of a column to be checked (in this case colnum
= 2), but I don't have its name.
我试过了,但它不起作用:
I tried this, but it does not work:
data<-subset(data,colnum!="Not Available")
推荐答案
df <- read.csv(text="A,22
B,333
C,Not Av.
D,Not Av.", header=F)
df[df[,2] != "Not Av.",]
这篇关于获取不包含列的给定值的子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!