[R] Changing the base of geom_bar in ggplot

Werner pensterfuzzer at yahoo.de
Fri Nov 30 11:50:14 CET 2012


Hi,

this is likely very easy to do but I don't find the right terms to search
for the solution. 
I want to show in a bar chart how much different categories deviate from the
average percentage change. 
Thus, in the following example I would like to set the zero line or base or
whatever it is called to the average of the values (=0.82) and the bars
should show the deviation from that, i.e. have the positive length of the
deviation of the value from the average.
I can do that by subtracting the average from each value but I would like to
have the zero line as the average to make it more clear.
How do you change the 'base'-line?

x <- data.frame(val=c(1.5, 3, -1.4, -1, 2), lab=letters[1:5])
ggplot(data=x, aes(x=lab, y=val)) + geom_bar(stat="identity") 

Many thanks for your help!

Best regards,
Werner



--
View this message in context: http://r.789695.n4.nabble.com/Changing-the-base-of-geom-bar-in-ggplot-tp4651407.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list