Skip to content
Prev 2159 / 63424 Next

Error in stripplot (was Re: [R] stripplot gets weird) (PR#195)

[Moved to R-bugs, hence R-devel, as this is now a bug report. I have
fixed the stripplot bug.]
On Thu, 13 May 1999, David Scott wrote:

            
More precisely, with rounding errors.
Yes. On my machine

Browse[1]> x
-2.61 -2.62  -1.9  -1.4  -1.2    -1 -0.41 -0.42   1.2   1.3     2   2.8 
 -2.6  -2.6  -1.9  -1.4  -1.2  -1.0  -0.4  -0.4   1.2   1.3   2.0   2.8 
Browse[1]> print(x, digits=17)                                                 
               -2.61                -2.62                 -1.9 
-2.59999999999999964 -2.60000000000000053 -1.89999999999999947 
                -1.4                 -1.2                   -1 
-1.39999999999999991 -1.19999999999999973 -1.00000000000000000 
               -0.41                -0.42                  1.2 
-0.39999999999999991 -0.40000000000000036  1.20000000000000018 
                 1.3                    2                  2.8 
 1.29999999999999982  1.99999999999999978  2.79999999999999982 
Browse[1]> factor(x)
 [1] -2.6 -2.6 -1.9 -1.4 -1.2 -1   -0.4 -0.4 1.2  1.3  2    2.8 
Levels:  -2.6 -2.6 -1.9 -1.4 -1.2 -1 -0.4 -0.4 1.2 1.3 2 2.8 
Browse[1]> unlist(xg)
-2.61 -2.62  -1.9  -1.4  -1.2    -1 -0.41 -0.42   1.2   1.3     2   2.8 
 -2.6  -2.6  -1.9  -1.4  -1.2  -1.0  -0.4  -0.4   1.2   1.3   2.0   2.8 
Browse[1]> unlist(xo)
-2.61 -2.62 -2.61 -2.62  -1.9  -1.4  -1.2    -1 -0.41 -0.42 -0.41 
    1     2     1     0     1     1     1     1     1     2     1 
-0.42   1.2   1.3     2   2.8 
    0     1     1     1     1 

The main problem is that 

Browse[1]> seq(0)
[1] 1 0

which is definitely wrong for here. stripplot should have 

    f <- function(x) seq(length=length(x))

En route, unlist gives very confusing labels, and I have added
use.names=FALSE.