Stacked bar chart in R (ggplot2) with y axis and bars as percentage of counts?

For the first graph, just add position = 'fill' to your geom_bar line!. You don't actually need to scale the counts as ggplot has a way to do it automatically ggplot(dat, aes(x = fruit)) + geom_bar(aes(fill = variable), position = 'fill').

For the first graph, just add position = 'fill' to your geom_bar line!. You don't actually need to scale the counts as ggplot has a way to do it automatically. Ggplot(dat, aes(x = fruit)) + geom_bar(aes(fill = variable), position = 'fill').

Thanks Ramnath, that's exactly what I need for the bars. When I do that, however, the y axis labels revert to a 0 to 1 scale. I'd like them to be 0 to 100.

Including y = ..counts..*100 or y = ..density..*100 in "aes" doesn't seem to work. Any ideas? – Steve Sep 1 '10 at 15:54 2 + scale_y_continuous("",formatter="percent").

The initial "" gets rid of the "count" label, but you could include any label you want. – James Sep 1 '10 at 16:05 Thanks a lot James, that works perfectly. – Steve Sep 1 '10 at 16:08 1 The plot now looks great, but in my real dataset there are NAs, ggplot interprets these as another factor level by default.Is there any way to turn this off (or remove NAs) within the plot function, so that the plot ignores NAs and just plots the other two levels out of 100%?

Thanks. – Steve Sep 1 '10 at 20:22 1 Steve. If you want to remove all NAs, then you can use na.

Omit(data) in the ggplot call. That would pass a data frame with all NAs removed. – Ramnath Sep 1 '107 at 16:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions