开发者

Create new data set that meets all of 4 conditions

开发者 https://www.devze.com 2022-12-30 05:46 出处:网络
I would like to create a new dataset where the foll开发者_StackOverflow中文版owing four conditions are all met.

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

精彩评论

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

关注公众号