【问题标题】:ggplot2/qplot ignores bins valued 0ggplot2/qplot 忽略值为 0 的 bin
【发布时间】:2014-11-24 13:33:45
【问题描述】:

所以,我在 R 中有这样的东西

f = factor(c(0,1,0,1,0), levels = c(0,1,2))

如果像这样绘制的话

plot(f)

生成了一个漂亮的图表,显示我有三个 0、两个 1 和零个 2。很好。直到我使用 qplot,那是

qplot(f)

生成一个超级图表,显示我有三个 0 和两个 1。不好。我确实需要保留有关第三级的信息。我该怎么做?

【问题讨论】:

    标签: r ggplot2 statistics


    【解决方案1】:

    试试这个:

    qplot(f) + scale_x_discrete(drop=FALSE)
    

    Arguments:drop

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-22
      • 1970-01-01
      • 2019-06-03
      • 2011-12-31
      • 1970-01-01
      • 2019-09-02
      • 1970-01-01
      相关资源
      最近更新 更多