如何在 R 中将密度表示为百分比?
当我在 R 中运行密度直方图时,纵轴将密度显示为分数。试试这个,例如: hist(rnorm(100), freq = FALSE)
看看纵轴如何显示“0.0”、“0.1”、“0.2”等,如何让它显示“0%”、“ 1%”、“2%”?
When I run a density histogram in R, the vertical axis shows densities as fractions. Try this, for example:hist(rnorm(100), freq = FALSE)
See how the vertical axis shows "0.0", "0.1", "0.2", etc. How can I make it display "0%", "1%", "2%"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西吗?
Something like this?
不要在
hist
中绘制垂直轴。通过axis
自行添加。然而,这确实具有误导性,因为密度与某物的百分比或比例不同。如果你要做类似的事情,
你会得到相同的分布,但现在你所有的密度都大了 10 倍,因为分布的规模小了 10 倍。
在 y 轴上绘制带有百分比的累积频率多边形或直方图会更有意义。
Don't plot the vertical axis in
hist
. Add it yourself viaaxis
.However, this is really misleading, because densities aren't the same as percentages or proportions of something. If you were to do something like
You get the same distribution, but now all your densities are 10 times larger in magnitude because the scale of the distribution is 10 times smaller.
It would make more sense to plot the cumulative frequency polygon or histogram with percentages on the y-axis.