[R] logical and NA -> %in%

Christian Hoffmann christian.hoffmann at wsl.ch
Thu Sep 5 08:40:10 CEST 2002


Hi Thomas, hi Tony

Thanks for the hint!  My motivation behind the question was to install all 
recommended packages:

install.packages(CRAN.packages()[CRAN.packages()[,3] %in% "recommended",1])

--christian

At 07:46 04.09.2002 -0700, you wrote:
>On Wed, 4 Sep 2002, Christian Hoffmann wrote:
>
> > Hi there, (sorry Martin, ich habe den falschen Empfaenger erwischt :-(  )
> >
> > Is there a function in the base package or elsewhere which returns TRUE and
> > not NA, even if NA is involved: (I did not find in the help system :-(  )
> >
> > if ( x==something & !is.na(something))
> >
> > or
> >
> > if ( x==something & !is.na(x==something))
> >
>
>x %in% something
>is TRUE if x is an element of something and FALSE otherwise, so your first
>example could be
>    if (x %in% something)
>
>         -thomas

Dr.sc.math.Christian W. Hoffmann
Mathematics and Statistical Computing
Landscape Dynamics and Spatial Development
Swiss Federal Research Institute WSL
Zuercherstrasse 111
CH-8903 Birmensdorf, Switzerland
phone: ++41-1-739 22 77    fax: ++41-1-739 22 15
e-mail: christian.hoffmann at wsl.ch
www: http://www.wsl.ch/staff/christian.hoffmann/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list