As you can see the percentages are on the wrong stacked bar which I'd like to change. I have tried position_fill(reverse = TRUE)
however it just wipes out my graph completely.
df2 <- data.frame(table(food$BusinessType, food$classification))
names(df2) <- c('Type', 'Rating', 'Count')
df2
df2 <- ddply(df2, .(Type), transform, percent=Count/sum(Count) *100)
df2 <- ddply(df2, .(Type), transform, pos = (cumsum(Count) - 0.9 * Count))
df2$label <- paste0(sprintf('%.0f', df2$percent), '%')
ggplot(df2, aes(x=Type, y=Count, fill=Rating)) +
geom_bar(stat = 'identity') +
geom_text(aes(y = pos, label = label), size =4) +
ggtitle('Business Type Ratings')