I don't know of one. Ideally, instead of a specifc function anyNA() function, any() could be perhaps be extended to any(x, FUN) where FUN returns a logical for an element of x, and implemented to find the 1st instance as you suggest.
Mike On 8/13/07, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > > 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 > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel