[R] length with missing values

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Oct 15 13:43:30 CEST 2004


"Dimitris Rizopoulos" <dimitris.rizopoulos at med.kuleuven.ac.be> writes:

> Hi Luis,
> 
> just use:
> 
> apply( mat, 2, function(x) length(x[!is.na(x)]) )


or:

apply(!is.na(mat),2,sum)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list