Skip to content
Prev 247500 / 398506 Next

Finding NAs in DF

Hi,

I hope you made a mistake in c(NA,"TWO","BOTH","ONE") because if not, I 
have no idea what you're looking for...

But would that do?
df <- data.frame(A=c(1,2,NA,NA),B=c(1,NA,NA,4))
apply(df,1, FUN=function(x) length(x[is.na(x)]))
[1] 0 1 2 1

There might be better ways to do it, but it works
HTH,
Ivan

Le 1/17/2011 11:01, Johannes Graumann a ?crit :