[R] R2.11.1 seq.int difference between by and length.out
Alexander
juschitz_alexander at yahoo.de
Tue Apr 10 18:14:34 CEST 2012
Thank you Michael
It is indeed the OS
identical(seq.int(0,1,length.out = 11), seq.int(0,1, by = 0.1)) # FALSE
Michael Weylandt wrote
>
> What difference is it you are worried about:?
>
> identical(seq.int(0,1,length.out = 11), seq.int(0,1, by = 0.1)) # TRUE
>
> Though that may be OS dependent.
>
> M
>
> On Tue, Apr 10, 2012 at 10:51 AM, Alexander <juschitz_alexander@>
> wrote:
>>
>> Berend Hasselman wrote
>>>
>>> On 10-04-2012, at 15:54, Alexander wrote:
>>>
>>>> I am working under R2.11.1 Windows and I was wondering why there is a
>>>> difference between
>>>>
>>>> seq.int(0,1,by=0.1)[4]-0.3
>>>> seq.int(0,1,length.out=11)[4]-0.3
>>>>
>>>> there is also the fact that
>>>>
>>>> seq(0,1,by=0.1)[4]-0.3
>>>> seq(0,1,length.out=11)[4]-0.3
>>>>
>>>> but I think this can be explained by floating precision...
>>>
>>>
>>> R FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html
>>>
>>> 7.31 Why doesn't R think these numbers are equal?
>>>
>> This explains what the difference, but the problem for
>>
>> seq(2)*seq(2)==2
>>
>> is not the same as
>>
>> 0.3+0.1-0.4==0
>>
>> There must be a difference in the calculation for by and length.out in
>> seq.int otherwise there wouldn't be a difference in seq.int
>>
>> seq.int(0,1,length.out=11)[4]-seq.int(0,1,by=0.1)[4]
>>
>> I am more interested in the generation of the sequence...
>>
>>
>> Berend Hasselman wrote
>>>
>>> Berend
>>>
>>>
>>>
>>>
>>> ______________________________________________
>>> R-help@ 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.
>>>
>>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/R2-11-1-seq-int-difference-between-by-and-length-out-tp4545683p4545854.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help@ 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.
>
> ______________________________________________
> R-help@ 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.
>
--
View this message in context: http://r.789695.n4.nabble.com/R2-11-1-seq-int-difference-between-by-and-length-out-tp4545683p4546134.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list