[R] Order of Dotplot output

Allison Bailey allison at soundgis.com
Fri Oct 19 18:18:51 CEST 2007


I'm just learning to work with R, and am having some difficulty controlling the output of my dotplot.

The default order of the function dotchart seems to be the largest value on the bottom and the smallest on the top.  I wanted it in the opposite order (which is how my data frame is currently sorted), so I used the following approach, which works

orderidx <- order(b2000$RR)
dotchart(b2000$RR[orderidx], labels = b2000$CNAME[orderidx],cex=0.5,xlab = "Proportion of Annual Catch, 2000")

However, the default behavior of the dotplot function (within the lattice library) seems to be to order the data in reverse alphabetical order (A on the bottom, Z on the top).  Can someone provide suggestions for controlling this order?  I would either prefer largest value (top) to smallest value (bottom) or alphabetical order (A top, Z bottom).

In addition, is there a way to control the labeling of each subplot?   When I use the following code: 

dotplot(CNAME ~ RR | RYEAR, data = btwlSubset, xlab = "% of annual catch ")

each subplot gets labeled with the word "RYEAR", rather than the value contained within the RYEAR column, which is what I would like.

Thanks for any suggestions,

Allison



More information about the R-help mailing list