ggplot2 binwidth 与因子(变量)?

发布于 2024-09-10 14:13:36 字数 363 浏览 1 评论 0原文

我有简单的直方图,但无法调整 binwidth:

qplot(factor(size_class),data=mydf,geom="histogram",binwidth = 0.01) 

size_class 是一个分类变量(char),它根据另一个大小变量将 mydf 分组。我想要得到的只是一个像这样的图表:

plot(table(mydf$size_class)

使用 ggplot2。上面的代码确实有效,但 binwidth 被忽略了。我觉得这与我的组变量有关,因为带有数字变量的示例有效。 我怎样才能用这种变量来完成它?

提前感谢您的帮助...

I have simple histogram, but can't adjust the binwidth:

qplot(factor(size_class),data=mydf,geom="histogram",binwidth = 0.01) 

size_class is a categorical variable (char) that groups mydf into groups according to another size variable. All I want to get is a graph like:

plot(table(mydf$size_class)

using ggplot2. The code above does work but binwidth is ignored somehow. I feel it has something to do with my group variable, since examples with numeric variables worked.
How can I get it done with this kind of variable?

thx in advance for any help…

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千と千尋 2024-09-17 14:13:36

您无法设置分类变量的 binwidth - 它没有任何意义,因为没有基础的连续比例。

You can't set the binwidth for a categorical variable - it doesn't mean anything because there isn't an underlying continuous scale.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文