hi everyone,
Is it possible to have info of two X axis in the same plot? I have the following data using mtcars dataset, and I would like to get the frequency and proportion for each of the carb categories within the 4 combinations of vs and am. That is, there will be 4 sets of bar charts, each has 6 bars. I know I can do it with facet_wrap(), but would it be possible to do it in a single plot without faceting? Thank you very much.
> dat=as.data.frame(with(mtcars,list(table(carb,vs,am),prop.table(table(carb,vs,am)))))
> ggplot(dat,aes(y=Freq,x=as.factor(carb)*as.factor(am),fill=as.factor(vs)))+stat_summary(fun='identity',geom='bar',position='dodge')
Warning messages:
1: In Ops.factor(as.factor(carb), as.factor(am)) :
‘*’ not meaningful for factors
2: In Ops.factor(as.factor(carb), as.factor(am)) :
‘*’ not meaningful for factors