[R] Help: barchart() {Lattice}

Peng Cai pengcaimaillist at gmail.com
Wed Dec 2 19:40:13 CET 2009


Hi R Users,

I'm using following data/code (data is attached also) to produce a stacked
barplot.

# Sample Data:
Names Col1 Col2 Col3
Row1 -20 40 -10
Row2 30 -20 40
Row3 30 10 -20
Row4 20 20 -10


# R Code:
dta<-read.table("data.txt", header=TRUE, row.names="Names")
barchart(data.matrix(dta),
     horizontal=FALSE,
     stack=TRUE,
     par.settings = simpleTheme(col = 3:5),
     auto.key=list(space="right"),
     border=NA
)

I need help with:

1. How can I remove the (y-axis) tick marks on the right side of the plot.
2. While reading in the data, I'm using "row.names=Names". Can I generalize
this? What I mean is if for some other data set, the row names column
has some other name (say Names2) or may be just blank. Can I still produce a
similar graph plotting row labels (in this case they are Row1, Row2, ...) on
x-axis.

Any help would be appreciated,

Thanks,
Peng
-------------- next part --------------
Names	Col1	Col2	Col3
Row1	-20	40	-10
Row2	30	-20	40
Row3	30	10	-20
Row4	20	20	-10


More information about the R-help mailing list