From @uh@rto_@nggono @ending from y@hoo@com  Fri Sep  7 23:34:42 2018
From: @uh@rto_@nggono @ending from y@hoo@com (Suharto Anggono Suharto Anggono)
Date: Fri, 7 Sep 2018 21:34:42 +0000 (UTC)
Subject: [Rd] Proposal: more accurate seq(from, to, length=n)
References: <1837118162.1355212.1536356082390.ref@mail.yahoo.com>
Message-ID: <1837118162.1355212.1536356082390@mail.yahoo.com>

In R,
seq(0, 1, 0.1)
gives the same result as
(0:10)*0.1.
It is not the same as
c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1) ,
as 0.1 is not represented exactly. I am fine with it.

In R,
seq(0, 1, length=11)
gives the same result as
seq(0, 1, 0.1).
However, for 
seq(0, 1, length=11),
it is more accurate to return
c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1) .
It can be obtained by
(0:10)/10.

When 'from', 'to', and 'length.out' are specified and length.out > 2, I propose for function 'seq.default' in R to use something like
from + ((0:(length.out - 1))/(length.out - 1)) * (to - from)
instead of something like
from + (0:(length.out - 1)) * ((to - from)/(length.out - 1)) .



[Rd] Proposal: more accurate seq(from, to, length=n)
Suharto Anggono Suharto Anggono