【发布时间】:2011-11-22 22:19:59
【问题描述】:
q1 <- qplot(factor(Q1), data=survey, geom="histogram", fill=factor(Q1), ylim=c(0,300))
options(digits=2)
q1 + geom_bar(colour="black") +
stat_bin(aes(label=..count..), vjust=-2, geom="text", position="identity") +
stat_bin(geom="text", aes(label=paste(..count../sum(..count..)*100,"%"), vjust=-0.75)) +
labs(x="Question # 1:\n 0 = Didn't respond, 1 = Not at all familiar, 5 = Very familiar") +
opts(title="Histogram of Question # 1:\nHow familiar are you with the term 'Biobased Products'?",
legend.position = "none",
plot.title = theme_text(size = 16, , vjust = 1, face = "bold"),
axis.title.x =theme_text(size=14), axis.text.x=theme_text(size=12),
axis.title.y=theme_text(size=14, angle=90), axis.text.y=theme_text(size=12))
如您所见,我得到的数字比需要的多,我希望 options(digits=2) 能做到,但我想不会。有什么想法吗?
【问题讨论】:
-
你试过用round()对它们进行四舍五入吗?
-
是的,这就是诀窍!谢谢。
标签: r ggplot2 bar-chart rounding