Hi,

is there a hasNA() / an anyNA() function in R?  Of course,

hasNA <- function(x) {
  any(is.na(x));
}

would do, but that would scan all elements in 'x' and then do the
test.  I'm looking for a more efficient implementation that returns
TRUE at the first NA, e.g.

hasNA <- function(x) {
  for (kk in seq(along=x)) {
    if (is.na(x[kk]))
      return(TRUE);
  }
  FALSE;
}

Cheers

Henrik

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to