[R] how to count number of elements in a vector that are not NA ?

David Huffer David.Huffer at csosa.gov
Tue Jul 7 21:25:24 CEST 2009


On Tuesday, July 07, 2009 3:20 PM, Godmar Back wrote:

 > ...That would be wrong, wouldn't it, if  the
 > other replies are correct....

Yes. It was wrong. This isn't:

   countN <- function ( v ) {
     length ( v ) - sum ( is.na ( v ) )
   }

But there are really tons of ways to do it. Even your way is not
wrong...

--
 David
 
 -----------------------------------------------------
 David Huffer, Ph.D.               Senior Statistician
 CSOSA/Washington, DC           david.huffer at csosa.gov




More information about the R-help mailing list