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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the
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
__
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?
sum(!is.na(x))
Peter
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
Hi Ralf,
The usual way (as others have shown you), takes advantage of the fact
that the logical values TRUE and FALSE are counted as 1 and 0,
respectively. is.na() returns TRUE if the value is NA, so to find how
many are not NA, the result is reversed using ' ! '. Similar logic
can be used to
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
project.org] On Behalf Of Joshua Wiley
Sent: Thursday, September 23, 2010 8:23 AM
To: Ralf B
Cc: r-help Mailing List
Subject: Re: [R] Length of vector without NA's
Hi Ralf,
The usual way (as others
5 matches
Mail list logo