I am trying to create a simple bar chart in ggplot2
with a categorical X (states) and continuous Y (dollars spent) but the Y axis is displayed in scientific notation.
I'm not understanding why scale_y_continuous(labels="comma")
is not working to do this.
An example of the data and error message are displayed below.
SS <- ggplot(statesummary,aes(factor(STATE),SPEND))+
geom_bar(stat="identity",col="red",fill="white")+
scale_y_continuous(labels="comma")
"Error in scale_labels.continuous(scale, major) :
Breaks and labels are different lengths"
STATE SPEND
NH 14,768,408
ME 882,312,066
RI 316,476,695
MA 2,939,600,063
CT 8,627,669,723
VT 968,411,831
Can someone please help me understand why this is and also what I should be doing? It seems like it should be a very easy conversion that would not require breaks.
There might be other issues, but the immediate one is that you need to remove the quotes around 'comma'. Additionally make sure you have the scales package.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.