我正在做免疫学的研究,想确定符合特定要求的基因的名称。
ifng5p <- df$Gene[which(as.numeric(df$Prop1) <= df[df$Genes == "Ifng", "Prop1.5p"]
& as.numeric(df$Prop1) >= df[df$Genes== "Ifng", "Prop1.5m"] & as.numeric(df$Prop1) <= df[df$Genes == "Ifng", "Prop1.5p"]
& as.numeric(df$Prop1) >= df[df$Genes=="Ifng", "Prop1.5m"])]我期望输出基因的名称(在‘Gene’列中),而我的输出如下所示:
factor(0)
49041 Levels: 0610005C13Rik 0610006L08Rik 0610009B22Rik 0610009E02Rik 0610009L18Rik ... Zzz3发布于 2019-05-02 10:59:00
factor(0)表示长度为0的factor类型的向量。你得到它是因为你的子集没有返回任何值。您可以在iris数据集上看到这样的示例:
# There are no cats in `iris` so it returns a vector of length 0
iris$Species[iris$Species == 'cat']
factor(0)
Levels: setosa versicolor virginica这是因为对于所有值,iris$Species == 'cat'都为FALSE,因此不返回值。table函数很好地对向量中的每个值进行了计数,我们可以使用它来查看iris$Species == 'cat'为我们提供了150个FALSE值和0个TRUE:
table(iris$Species == 'cat')
FALSE
150 https://stackoverflow.com/questions/55945063
复制相似问题