ggplot2 binwidth 与因子(变量)?
我有简单的直方图,但无法调整 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法设置分类变量的 binwidth - 它没有任何意义,因为没有基础的连续比例。
You can't set the binwidth for a categorical variable - it doesn't mean anything because there isn't an underlying continuous scale.