[R] problem with "which"

Berwin A Turlach berwin at maths.uwa.edu.au
Thu Apr 24 06:09:03 CEST 2008


G'day Melanie,

On Wed, 23 Apr 2008 17:46:56 -1000
Melanie Abecassis <Melanie.Abecassis at noaa.gov> wrote:

> This doesn't seem to happen with integers.
> Am I missing something ?? 

Yes, FAQ 7.31:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

> Is there a better function for non-integers ?

> which(sapply(tt, function(x) isTRUE(all.equal(x,1.7))))
[1] 8

seems to work.

HTH.

Cheers,

	Berwin

=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability        +65 6515 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba



More information about the R-help mailing list