Ordering scales in xYplot.Hmisc
On Friday 01 April 2005 12:41, Jose A. Hernandez wrote:
Dear R community, I am using xYplot() from the Hmisc package. The package works great to plot means + CI. But I am having issues handling the scales. I am plotting "Soil Clay content" vs "Soil depth" by "land use". Usually in this type of graphs it is better to place the variable "soil depth" in the y-axis and it should be ordered downward by depth (0-5 cm, 5-10 cm, 10-20 cm). I can't figure out how to sort/order the scale to obtain the graph I need, any insights will be appreciated. Best regards and have a nice weekend, Jose
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 0.1
year 2004
month 11
day 15
language R
################ CODE #####################
library(Hmisc)
ron <- read.csv("http://www.tc.umn.edu/~jahernan/ron.csv")
ron
#sapply(ron,class)
ron$depth <- factor(ron$depth)
levels(ron$depth) <- c("0-5", "5-10", "10-20")
Specify the order that you want instead of relying on the default. e.g.,
ron$depth <- factor(ron$depth, levels = rev(sort(unique(ron$depth))))
levels(ron$depth) <- c("10-20", "5-10", "0-5")
Deepayan
ron
Dotplot(depth ~ Cbind(clay_mean,clay_lower,clay_upper) |land,
data=ron,
xlim=c(22,36),
ylab="Soil Depth [cm]",
xlab="Clay Content [%]",
main=c("Clay Content by Soil Depth and Land Use. Rondonia,
Brasil"))
################ CODE #####################