【问题标题】:R Histogram dbplot count bars oriented sideways with default parametersR 直方图 dbplot 计数条横向使用默认参数
【发布时间】:2020-04-08 23:44:01
【问题描述】:

谁能帮我弄清楚为什么下面的代码给了我一个与预期不同的情节?我在想我不小心在某个地方使用了一些全局选项,但我不知道是什么。请注意,代码会在错误的轴上生成频率(计数)条。

library(sparklyr)
library(dbplot)
library(dplyr)

sc <- spark_connect(master = "local", version = "2.3")
cars <- copy_to(sc, mtcars)
dbplot_histogram(cars, hp)

这是我系统上的结果图:

【问题讨论】:

    标签: r ggplot2 histogram data-visualization


    【解决方案1】:

    似乎它可能是 dbplot_histogram 的默认值。运行您的代码时,我得到了同样的结果,但这不是全局选项问题,因为 geom_histogram 工作正常。

    #horizontal
    dbplot_histogram(mtcars, hp, bins = 30, binwidth = NULL)
    

    #vertical ggplot(mtcars, aes(x=hp)) + geom_histogram()

    【讨论】:

    • 那么一定是某个地方出了问题,因为我得到的情节会说只有 18 辆汽车,但事实并非如此。我最初试图重现Ch. 4 of The R in Spark 中的第一个情节,但这对于堆栈溢出来说有点长。
    猜你喜欢
    • 2020-08-04
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多