[R] dotchart questions

Chuck Cleland ccleland at optonline.net
Fri May 28 21:10:30 CEST 2004


   Instead of dotchart, you might try a lattice dotplot after 
restructuring the data.

FACT1 <- vector("character", 15)

for(i in 1:15){
     FACT1[i] <- paste(rep(LETTERS[i], 20), collapse ="")}

mydata <- data.frame(FACT1 = rep(FACT1, 9),
              FACT2 = rep(c("E", "F", "G"), c(15, 15, 15)),
              RESPVAL = runif(45*3),
              RESPVAR = rep(c("V1", "V2", "V3"), c(45, 45, 45)))

library(lattice)

trellis.device(width=11, height=8.5, new = FALSE, col = FALSE,
              bg = "white")

dotplot(FACT1 ~ RESPVAL | RESPVAR * FACT2, data = mydata,
              between = list(x = 0.5, y = 0))

hope this helps,

Chuck Cleland

Richard Valliant wrote:
> I am trying to put 3 dotcharts side-by-side with minimal space between
> each.  Each chart is for a different variable, but the vertical axes are
> the same. 
>  
> I want to have vertical axis labels on the lefthand chart but no
> vertical axis labels on the other two. Plus, I would like very little
> space between charts 1 & 2 and between charts 2 & 3.
>  
> I have one approach but am not too happy with the results. A stripped
> down version of the code is below. Matrix A has the row labels (which
> are about 20 characters long in the real data). Matrix A1 has no row
> labels.
>  
>  
> A <- matrix(1:12, ncol=3, byrow=F)
> A1 <- A
> dimnames(A) <- list(letters[1:4], letters[5:7])
> dimnames(A1) <- list(rep("",4), rep("",3))
>  
> par(mfrow = c(1,3), mgp = c(1.75, 1, 0.5), mar = c(3, 0, 1.5, 0), oma =
> c(2,2,2,2))
>  
> dotchart(A)
> dotchart(A1)
> dotchart(A1)
> 
> Two questions:
> (1) Is there a way with par or something else to make the charts closer
> together.
> (2) With a lot of rows (45 in the real data) is there a way to control
> row spacing (other than getting rid of some rows).

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list