[Rd] rhs of == does not work with a list of items. should it ? (PR#1173)

ligges@statistik.uni-dortmund.de ligges@statistik.uni-dortmund.de
Thu, 15 Nov 2001 08:24:55 +0100 (MET)


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

That's not a bug!
R extends the vector 4:5 to have the same length as 1:10 and compares
these two vectors:

4 1
5 2
4 3
5 4
4 5
5 6
4 7
5 8
4 9
5 10

So there is no position with "4:5 == 1:10"!
Test it with: 2:10 == 4:5.

What you want is  (I guess):
 1:10 %in% 4:5

Uwe Ligges

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._