Thanks. This is what I was referring to: x <- rep(NA, 3) is.na(x) [1] TRUE TRUE TRUE
if (is.na(x)) {print("True")} [1] "True" Warning message: In if (is.na(x)) { : the condition has length > 1 and only the first element will be used You are of course right - the warning is generated by if(), not by is.na() and the reason for the warning is that is.na() returns a vector if applied to a vector. I should have been more clear. Cheers, B. On Dec 20, 2014, at 3:29 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > This may be out of context, but on the face of it, this claim is wrong: > > On 20/12/2014, 1:57 PM, Boris Steipe wrote: > "Moreover is.na() behaves differently when evaluated on its own, or as > the condition of an if() statement." > > The conditions in an if() statement are not evaluated in special > conditions at all. The only way you'll get a different value is if the > argument to is.na() does tricky stuff like looking at the evaluation stack. > > Duncan Murdoch ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.