Solved – Why is the y-axis in this R plot showing invalid percentage values

ggplot2r

Why are the percentages in the y-axis of this bar chart displayed incorrectly (values larger than 100%) and how can I fix it?

qplot(tctype,tccount,data=categ,xlab="Type",ylab="",geom = "bar")+ scale_y_continuous(formatter="percent")

enter image description here

This is the data frame

categ
                  tctype tccount
1  inthread (10 or less)   16228
2 occasional (10 to 100)    3561
3 addicted (100 to 1000)     327
4        communal(1000+)      10

Best Answer

As mark999 mentioned in the comment above, I needed to normalize the data like this:

plot(tctype,tccount/sum(tccount),data=categ,xlab="Type",ylab="",geom = "bar")+ scale_y_continuous(formatter="percent") 
Related Question