[R] Length of vector without NA's
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Thu Sep 23 17:11:52 CEST 2010
try this
sum(!is.na(x))
I hope it helps.
Best,
Dimitris
On 9/23/2010 5:08 PM, Ralf B wrote:
> Hi,
>
> this following code:
>
> x<-c(1,2,NA)
> length(x)
>
> returns 3, correctly counting numbers as well as NA's. How can I
> exclude NA's from this count?
>
> Ralf
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
More information about the R-help
mailing list