R question. Create a new dataset matching all 4 conditions

I would like to create a new dataset where all four conditions are 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!

+1
source share
1 answer

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

The only & is a vectorized function, and double && is unary (usually used in an if , for example).

+9
source

Source: https://habr.com/ru/post/909152/


All Articles