Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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
share|improve this question
3  
Maybe try qplot(tctype,tccount/sum(tccount),data=categ,xlab="Type",ylab="",geom = "bar")+ scale_y_continuous(formatter="percent") – mark999 Jun 18 '11 at 6:35
3  
It's displaying it correctly, 16228 = 1622800%, you'll have to normalize the data yourself as suggested. – nico Jun 18 '11 at 8:06
I see, I thought the formatter part would do it automatically. This is exactly what I needed. Thanks a lot! – amh Jun 19 '11 at 16:46

1 Answer

up vote 1 down vote accepted

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") 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.