【问题标题】:How to break up columns into invervals of size 0.02 of a histogram on the x-axis?如何将列分解为 x 轴上直方图大小为 0.02 的间隔?
【发布时间】:2019-07-03 18:50:14
【问题描述】:

如何在 R-Studio 中将柱状图的 x 轴上的列拆分为大小为 0.02 的间隔?

eye = LEFTEYE$X__1
breaks = seq(0.04, 1.08, by=0.02)
eye.cut = cut(eye, breaks, right=FALSE)

eye.freq = table(eye.cut)
cbind(eye.freq)

hist(eye.freq, xlab="Cylindrical Power Measurements for the Left Eye")

【问题讨论】:

    标签: r statistics histogram


    【解决方案1】:

    您可以通过使用 hist() 中的中断参数来实现此目的。 Breaks 采用 x 轴的上限和下限,然后是带参数 by 的 bin 宽度。

    例如此代码使用 iris 数据集,将 x 轴的下限设置为 4,上限设置为 8,并将 bin 宽度设置为 0.02。

    hist(iris$Sepal.Length, breaks=seq(4,8,by=0.02))

    【讨论】:

    • 谢谢!该代码帮助我处理 x 轴,但现在 y 轴(频率)在 4 处截止,即使我更改 ylim = c(0,10)。有些频率高于 for 所以这是个问题。
    • @Boognish hist(iris$Sepal.Length, breaks=seq(0,10,by=0.02)) 应该可以工作,xlim 在breaks 参数中设置
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    • 2022-11-10
    • 2023-03-26
    • 2021-12-14
    • 2016-01-20
    • 1970-01-01
    相关资源
    最近更新 更多