[R] Labeling barplot bars by multiple factors
Mike Lawrence
Mike.Lawrence at dal.ca
Wed May 27 18:54:37 CEST 2009
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. ~
More information about the R-help
mailing list