How about if (is.na(c(x,1))[1]) ....... --- Gregory Wall <[EMAIL PROTECTED]> wrote:
> > Hello, > > I've searched the list but haven't found anything > really applicable to my > question. Any advice would be super. > > I'm working on a snippet of R code and I have a > function with a prototype > like this: > > foo <- function( x, ... ){ > if( is.na(x)[1] ) {etc...} > } > > Where x is typically a vector of bools. > > At times, however, x can be NA, and yet at other > super rare times x can be > the result of this type of comparison: > > c(4,5,13,2,3,4,5,7) == numeric(0) > > which produces logical(0). When this is the case, > if( is.na(x)[1] ) isn't > happy. > > I'm trying to create a condition to my "if" > statement inside foo that only > is true when x is NA but that doesn't die when its a > logical(0). > > Any suggestions on how best to approach this? > > As always, thanks a bunch, > > Greg > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.