Re: [R] problem with "which"

From: Berwin A Turlach <berwin_at_maths.uwa.edu.au>
Date: Thu, 24 Apr 2008 12:09:03 +0800

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


R-help_at_r-project.org 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. Received on Thu 24 Apr 2008 - 04:11:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Apr 2008 - 04:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive