[R] Counting NA?

Laurent Gautier laurent at cbs.dtu.dk
Wed Oct 23 10:53:30 CEST 2002


On Wed, Oct 23, 2002 at 02:48:20AM -0400, Matej Cepl wrote:
> Hi,
> 
> how to do quickly equivalent of the following?
> 
> 	counter = 0
> 	for(i in 1:length(data$S2)) {
> 		if(!is.na(data$S2[i])) {
> 			counter = counter + 1
> 		}
> 	}
> 


Try:

sum(is.na(data$2))



Hopin' it helps,


L.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list