[R] stripplot gets weird

David Scott d.scott at auckland.ac.nz
Thu May 13 03:41:24 CEST 1999


After thinking that the name difference was a problem, or that attaching
the dataframe was a problem, I think it might be something to do with
internal representation of numbers:

aitken/Exam9> R

R : Copyright 1999, The R Development Core Team
Version 0.63.3  (March 6, 1999)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type    "?license" or "?licence" for distribution details.

R is a collaborative project with many contributors.
Type    "?contributors" for a list.

Type    "demo()" for some demos, "help()" for on-line help, or
        "help.start()" for a HTML browser interface to help.
Type    "q()" to quit R.


> impurity.df<-read.table("impurities.dat",header=T)
> impurity.df
   supplier1 supplier2
1        3.8       1.8
2        3.5       2.2
3        4.1       1.3
4        2.5       5.1
5        3.6       4.0
6        4.3       4.7
7        2.1       3.3
8        2.9       4.3
9        3.2       4.2
10       3.7       2.5
11       2.8       5.4
12       2.7       4.6
> supp.diff<-impurity.df$supplier1-impurity.df$supplier2
> stripplot(supp.diff,method="stack")
Warning in y + (unlist(xo) - 1) * offset * csize : longer object length
        is not a multiple of shorter object length
Error: x and y lengths differ
> dput(supp.diff)
c(2, 1.3, 2.8, -2.6, -0.4, -0.4, -1.2, -1.4, -1, 1.2, -2.6, -1.9
)
> supp.diff<-c(2, 1.3, 2.8, -2.6, -0.4, -0.4, -1.2, -1.4, -1, 1.2, -2.6,
-1.9
+ )
> stripplot(supp.diff,method="stack")
>

Works!!!

The bit of code inside stripplot that is playing up is intended to
determine where there are repeated values, and create a sequence
numbering the values:
    f <- function(x) seq(length(x))
    for (i in 1:n) {
        x <- groups[[i]]
        y <- rep(i, length(x))
        if (method == 2) 
            y <- y + runif(length(y), -jitter, jitter)
        else if (method == 3) {
            xg <- split(x, factor(x))
            xo <- lapply(xg, f)
            x <- unlist(xg)
            y <- y + (unlist(xo) - 1) * offset * csize



Here is the data in the file (it is also attached):
supplier1       supplier2
3.8     1.8
3.5     2.2
4.1     1.3
2.5     5.1
3.6     4.0
4.3     4.7
2.1     3.3
2.9     4.3
3.2     4.2
3.7     2.5
2.8     5.4
2.7     4.6


And a copy of the necessary bits of code:
impurity.df<-read.table("impurities.dat",header=T)
supp.diff<-impurity.df$supplier1-impurity.df$supplier2
stripplot(supp.diff,method="stack")
supp.diff<-c(2, 1.3, 2.8, -2.6, -0.4, -0.4, -1.2, -1.4, -1, 1.2, -2.6,
-1.9)
stripplot(supp.diff,method="stack")


David Scott

_________________________________________________________________
David Scott     Division of Science and Technology, Tamaki Campus
                The University of Auckland, PB 92019
                Auckland        NEW ZEALAND
Phone: +64 9 373 7599 ext 6830     Fax: +64 9 308 2377 or 373 7001
Email:  d.scott at Auckland.ac.nz or dscott at scitec.auckland.ac.nz
-------------- next part --------------
supplier1	supplier2
3.8	1.8
3.5	2.2
4.1	1.3
2.5	5.1
3.6	4.0
4.3	4.7
2.1	3.3
2.9	4.3
3.2	4.2
3.7	2.5
2.8	5.4
2.7	4.6


More information about the R-help mailing list