powered by
countNAs used in apply to count the number of NAs in a vector
countNAs(invect)
vector of values
A single value of zero or the number of NAs
# NOT RUN { x <- matrix(trunc(runif(20)*10),nrow=4,ncol=5) diag(x) <- NA print(x) apply(x,1,countNAs) # }
Run the code above in your browser using DataLab