An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090527/17356be3/attachment-0001.pl>
Labeling barplot bars by multiple factors
4 messages · Thomas Levine, Michael Lawrence, Jim Lemon
You can get something close with ggplot2:
library(ggplot2)
my_data = expand.grid(
A = factor(c('A1','A2'))
, B = factor(c('B1','B2'))
, C = factor(c('C1','C2'))
)
my_data$DV = rnorm(8,mean=10,sd=1)
p = ggplot()
p = p + layer(
geom = 'bar'
, stat = 'identity'
, data = my_data
, mapping = aes(
x = C
, y = DV
, fill = B
)
, position = 'dodge'
)
p = p + facet_grid(
A ~ .
)
p = p + coord_flip()
print(p)
On Wed, May 27, 2009 at 1:01 PM, Thomas Levine <thomas.levine at gmail.com> wrote:
I want to plot quantitative data as a function of three two-level factors. How do I group the bars on a barplot by level through labeling and spacing? Here <http://www.thomaslevine.org/sample_multiple-factor_barplot.png>'s what I'm thinking of. Also, I'm pretty sure that I want a barplot, but there may be something better. Tom ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~
Thomas Levine wrote:
I want to plot quantitative data as a function of three two-level factors. How do I group the bars on a barplot by level through labeling and spacing? Here <http://www.thomaslevine.org/sample_multiple-factor_barplot.png>'s what I'm thinking of. Also, I'm pretty sure that I want a barplot, but there may be something better.
Hi Tom, You may find that the hierobarp function in the plotrix package will do what you want. Jim
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090528/45a15b2d/attachment-0001.pl>