[R] Counting NA?

Jan_Svatos@eurotel.cz Jan_Svatos at eurotel.cz
Wed Oct 23 15:11:03 CEST 2002


Hi,

length(data$S2[is.na(data$S2)]) #counts NA
length(data$S2[!is.na(data$S2)]) #counts NOT NA

is the easiest solution I know.
JS


- - - Original message: - - -
From: owner-r-help at stat.math.ethz.ch
Send: 23.10.2002 9:50:19
To: r-help at stat.math.ethz.ch
Subject: [R] Counting NA?

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
  }
 }

I have imagined something like length(x,na.rm=TRUE).

How can I get values usually taken from tables like z-score,
values of t distribution etc.? I could not find them among
values mentioned in info file.

Thanks,

Matej

--
Matej Cepl, matej at ceplovi.cz, PGP ID# D96484AC
138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488

The difference between death and taxes is death doesn't get worse
every time Congress meets
    -- Will Rogers

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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