[Rd] R problem with the seq function (PR#13295)

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Nov 17 15:36:56 CET 2008


>From the FAQ,  section 9.1

   If a command does the wrong thing, that is a bug.  But be sure you know
   for certain what it ought to have done.  If you aren't familiar with the
   command, or don't know for certain how the command is supposed to work,
   then it might actually be working right.  For example, people sometimes
   think there is a bug in R's mathematics because they don't understand
   how finite-precision arithmetic works.  Rather than jumping to
   conclusions, show the problem to someone who knows for certain.
   Unexpected results of comparison of decimal numbers, for example `0.28 *
   100 != 28' or `0.1 + 0.2 != 0.3', are not a bug.  See FAQ 7.31 for more
   details.

As a student, you should seek advice from your teachers about things you 
'really don't understand'.



On Mon, 17 Nov 2008, fabien.roussel at imr.no wrote:

> Hello,
>
> =20
>
> Something wrong happens when I use the seq (function). Here it is an exampl=
> e from my R console, I have the R version 2.7.2 (2008-08-25) running on Mic=
> rosoft windows XP Version 2002 Service Pack 3, and my machine is a Dell Opt=
> ilex GX280 with a processor Intel Pentium 4 CPU 2.80GHhz, 0.99 GB RAM:
>
> =20
>
> =20
>
>> r=3Dseq(0.150,0.180,0.001)
>
> =20
>
>> r[16]
>
> =20
>
> [1] 0.165
>
> =20
>
>> class(r[16])
>
> =20
>
> [1] "numeric"
>
> =20
>
>> for (i in (150:180)/1000)
>
> =20
>
> +  show(which(r=3D=3Di))
>
> =20
>
> [1] 1
>
> [1] 2
>
> [1] 3
>
> [1] 4
>
> [1] 5
>
> [1] 6
>
> [1] 7
>
> [1] 8
>
> [1] 9
>
> [1] 10
>
> [1] 11
>
> [1] 12
>
> [1] 13
>
> [1] 14
>
> [1] 15
>
> integer(0)
>
> integer(0)
>
> integer(0)
>
> integer(0)
>
> integer(0)
>
> integer(0)
>
> integer(0)
>
> [1] 23
>
> [1] 24
>
> [1] 25
>
> [1] 26
>
> [1] 27
>
> [1] 28
>
> [1] 29
>
> [1] 30
>
> [1] 31
>
> =20
>
> Could you explain me why from the 16th element to the 22nd the value is int=
> eger (0)  ? I really don't understand... so it would be very nice of you to=
> do it.
>
> =20
>
> Best regards=20
>
> =20
>
> Fabien Roussel,=20
>
> Student=20
>
> Institute of Marine Research Troms=F8
>
> Norway
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list