[Rd] rhs of == does not work with a list of items (PR#1172)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Thu, 15 Nov 2001 10:00:50 +0100 (MET)


(1) There are no lists here!  You have numeric vectors, not lists.


(2) The normal vector-recycling rules apply.  It does
1 == 4, 2 == 5, 3 == 4, 4 == 5,  5 == 4, ....

Try

> 1:10 == 5:4
 [1] FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE


(3) For what you appear to want

> x %in% 4:5
 [1] FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE

is the way to get it.


(4) It is better to read the reference manual or a good book or post to
R-help if you don't understand what R is doing.  See the section in the
FAQ

  9.1 What is a bug?

R is a volunteer project, and bug reports take valuable time.


On Thu, 15 Nov 2001 Paul.White@dsto.defence.gov.au wrote:

> > Hello bug people,
> >
> > Version:
> >  platform = i686-pc-linux-gnu
> >  arch = i686
> >  os = linux-gnu
> >  system = i686, linux-gnu
> >  status =
> >  major = 1
> >  minor = 3.1
> >  year = 2001
> >  month = 08
> >  day = 31
> >  language = R
> >
> > is this a bug ?
> >
> > x <- 1:10
> > x==4:5
> >  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> >
> > Nothing said it should but nothing said it shouldn't . My expectation was
> > that it would successively try
> > each of the values in the list and or the result for each item in the x
> > vector. ie it would pick out all the matches
> of 4 or 5.
>
> > [1] FALSE FALSE FALSE  TRUE TRUE FALSE FALSE FALSE FALSE FALSE
> >
> > Paul
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel 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-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._