开发者

Create new data set that meets all of 4 conditions

I would like to create a new dataset where the foll开发者_StackOverflow中文版owing four conditions are all met.

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

Thanks!


Then use the & operator:

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, ]

A single & is a vectorized function, while a double && is unary (typically used in an if statement, for instance).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜