Hi: Following up on Ben's suggestion re ggplot2, here's a manufactured example:
# Fake data: mortrate <- round(runif(100), 3) dd <- data.frame(rate = mortrate, moe = 1.96 * sqrt(mortrate * (1 - mortrate))/10, hosp = factor(paste('H', 1:100, sep = ''))) dim(dd) [1] 100 3 # Set up the plot: ymin and ymax are input parameters to geom_pointrange g <- ggplot(dd, aes(x = hosp, y = rate, ymin = rate - moe, ymax = rate + moe)) # Version with hospitals in lexicographic order (rather useless): g + geom_pointrange() + geom_hline(aes(yintercept = mean(rate))) + scale_x_discrete(expand = c(0.01, 0.01)) + coord_flip() + theme_bw() + opts(axis.text.y = theme_text(size = 5, hjust = 1)) # Version with hospitals sorted by rate (better): g + geom_pointrange(aes(x = reorder(hosp, rate, mean))) + geom_hline(aes(yintercept = mean(rate))) + scale_x_discrete(expand = c(0.01, 0.01)) + coord_flip() + theme_bw() + opts(axis.text.y = theme_text(size = 5, hjust = 1)) Hope you like it... Dennis On Tue, Oct 19, 2010 at 4:59 PM, XINLI LI <lihaw...@gmail.com> wrote: > Dear R Users: > > I have the individual mortality rate and 95% CI of 100 hospitals, > how to do the plot with the individual hospital in the Yaxis, and the > mortality rate and 95% CI in the Xais and a overall mean as a reference > line? > > Thanks and regards, > > Xin > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.