From jari.oksanen at oulu.fi  Thu Feb  7 11:20:34 2013
From: jari.oksanen at oulu.fi (Jari Oksanen)
Date: Thu, 7 Feb 2013 10:20:34 +0000
Subject: [Rd] It's a BUG or a Feature? Generating seq break
	comparing	operators
In-Reply-To: <CAAmySGMHJiUEEWv4UwjyZo4FcQizygwikGF6yuy6WTpUdo7yyA@mail.gmail.com>
References: <DB673033-01F6-49EA-B3C0-E6E9215E51A8@ieo.eu>
	<CAAmySGMHJiUEEWv4UwjyZo4FcQizygwikGF6yuy6WTpUdo7yyA@mail.gmail.com>
Message-ID: <66C03CD1145C95448A4D73676DD9C2ED40D5EA@nippu1.univ.yo.oulu.fi>

This should be FAQ 0.0. No other thing is asked as frequently as this. This is the FAQest of all FAQs, and a mother of all FAQs. At least this should be in R posting guide: "Read FAQ 7.31 before posting!"

Cheers, Jari Oksanen

On 07/02/2013, at 12:13 PM, R. Michael Weylandt wrote:

> R FAQ 7.31
> 
> Cheers,
> MW
> 
> On Thu, Feb 7, 2013 at 10:05 AM, Davide Rambaldi <davide.rambaldi at ieo.eu> wrote:
>> Hello everybody:
>> 
>> I get a strange behavior with seq, take a look at this:
>> 
>>> msd <- seq(0.05,0.3, 0.01)
>>> msd[13]
>> [1] 0.17
>>> class(msd)
>> [1] "numeric"
>>> class(msd[13])
>> [1] "numeric"
>>> typeof(msd[13])
>> [1] "double"
>> 
>> now the problem:
>> 
>>> msd[13] == 0.17
>> [1] FALSE
>> 
>> It is strange only to me?
>> 
>> Consider that:
>> 
>>> 0.17 == 0.17
>> [1] TRUE
>> 
>> and also
>> 
>>> a <- c(0,1,0.17)
>>> a
>> [1] 0.00 1.00 0.17
>>> a[3] == 0.17
>> [1] TRUE
>> 
>> It's a BUG in seq? I suspect something related to doubles ?
>> 
>> sessionInfo():
>> 
>> R version 2.15.2 (2012-10-26)
>> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>> 
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>> 
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>> 
>> loaded via a namespace (and not attached):
>> [1] tools_2.15.2
>> 
>> 
>> -----------------------------------------------------------
>> PLEASE NOTE MY NEW EMAIL ADDRESS
>> -----------------------------------------------------------
>> 
>> -----------------------------------------------------
>> Davide Rambaldi, PhD.
>> -----------------------------------------------------
>> IEO ~ MolMed
>> [e] davide.rambaldi at ieo.eu
>> [e] davide.rambaldi at gmail.com
>> 
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Jari Oksanen, Dept Biology, Univ Oulu, 90014 Finland
jari.oksanen at oulu.fi, Ph. +358 400 408593, http://cc.oulu.fi/~jarioksa



[Rd] It's a BUG or a Feature? Generating seq break comparing operators
Jari Oksanen