I\'m having troubles creating a stacked barchart with aggregate data. When dealing with aggregate tables from other people\'s reports I generally use Excel, but I\'d like to
reshape
your data:
library(reshape2)
df <- melt(D)
And simply plot it :)
ggplot(df, aes(x = factor(Education), y = value, fill = factor(variable))) +
geom_bar() + facet_grid(.~Group) +
ylab('') + xlab('') + opts(title = '') + scale_fill_discrete('') +
theme_bw() +
opts(axis.text.x=theme_text(angle = 45, hjust = 1, vjust = 1))
Where the first line creates sets aesthetics, second line adds bar
layer and the facet
, on the 3rd line we remove unwanted texts from the plot, the 4th line sets the b&w
theme and on the last line we rotate the x asis labels.