Thank you Bert, Sorry if it sounded like a complain, this is not what I meant.
The situation I had was: given a vector "v" containing integers or NA's, I wanted to know if after excluding the NA's all the remaining observations were 2's. Naively, I assumed that: all(na.omit(v) == 2) would do the work, but now I see that it fails if, for example, v = rep(NA, 10) But that's okay, just a matter of adding an extra test (already done). When I asked for clarification about the reasons for this, I assumed that: if all(v) is TRUE ==> any(v) is TRUE; for all " (logical) v"... When actually: if all(v) is TRUE ==> any(v) is TRUE; for all "(logical) v of length >= 1". Thank you, benilton On Nov 29, 2006, at 6:35 PM, Bert Gunter wrote: > Merely convention. > > NULL == 2 <==> logical(0), that is, a logical vector of length 0. > It makes > sense (at least to me) that any(logical(0)) is FALSE, since no > elements of > the vector are TRUE. all(logical(0)) is TRUE since no elements of > the vector > are FALSE. > > I think these are reasonable and fairly standard conventions, but > even if > you disagree, they are certainly not worth making a fuss over and > certainly > cannot be changed without breaking a lot of code, I'm sure. > > Bert Gunter > Nonclinical Statistics > 7-7374 > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Benilton > Carvalho > Sent: Wednesday, November 29, 2006 2:21 PM > To: R-Mailingliste > Subject: [R] tests for NULL objects > > Hi Everyone, > > After searching the subject and not being successful, I was wondering > if any you could explain me the idea behind the following fact: > > all(NULL == 2) ## TRUE > any(NULL == 2) ## FALSE > > Thanks a lot, > > Benilton > > -- > Benilton Carvalho > PhD Candidate > Department of Biostatistics > Johns Hopkins University > > ______________________________________________ > R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.