1

我想创建一个满足以下四个条件的新数据集。

rowSums(is.na(UNCA[,11:23]))<12

rowSums(is.na(UNCA[,27:39]))<12

rowSums(is.na(UNCA[,40:52]))<12

rowSums(is.na(UNCA[,53:65]))<12

谢谢!

4

1 回答 1

9

然后使用&运算符:

UNCA.new <- UNCA[rowSums(is.na(UNCA[,11:23])) < 12 & 
                 rowSums(is.na(UNCA[,27:39])) < 12 & 
                 rowSums(is.na(UNCA[,40:52])) < 12 &  
                 rowSums(is.na(UNCA[,53:65])) < 12, ]

single&是向量化函数,而 double&&是一元的(例如,通常在if语句中使用)。

于 2010-05-16T17:20:15.397 回答