Skip to content

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:

  
    
#
Thomas Levine wrote:
Hi Tom,
You may find that the hierobarp function in the plotrix package will do 
what you want.

Jim