【问题标题】:Error with hist function (need finite 'ylim' values) (breaks related)hist 函数出错(需要有限的 'ylim' 值)(中断相关)
【发布时间】:2016-09-06 06:58:56
【问题描述】:

谁能告诉为什么在矩阵 CHh 上运行 hist 会给出错误“plot.window(xlim, ylim, "", ...) 中的错误:需要有限的 'ylim' 值”?如果我消除 min 函数,错误就会消失。然而我不明白为什么这代表了一个问题。谢谢。

CFh <-structure(c(-0.64, 0.34, 0.65, 0.26, -0.64, 0.92, -0.64, -0.1, -0.41, -0.36, 0.16, 0.92, 1.43, -0.41, 0.65, 0.28, 0.47, 0.35, -0.54, 0.65, 0.28, -0.1, 0.92, -0.36, 0.25, 0.34, -0.34, 0.07, 0.65, 0, -0.04, 0.47, 0.78, 0.47, 1.43, -0.23, -0.41, 0.28, 0.62, 0.35, -0.34, -0.23, -0.36, 0.28, 0.26, 0.03, 0.28, 0.07, 0.47, 0.63, 0.35, 0.47, 0, -0.28, 0.34, 0.16, 0.62, -0.04, 0.03, -0.41, -0.34, -0.64, -0.32, -0.28, -0.04, -0.36, 0.34, 0.47, 0.63, 0.62, 0, -0.04, -0.23, 0.65, -0.04, 0.47, -0.64, 0, -0.34, 0.28, -0.1, -0.28, 0.35, -0.34, -0.04, 0.63, 0.92, 0.35, 0.25, 0.34, 0.25, 0.34, 0.16, -0.36, 0, 0.28, 0.28, -0.28, -0.34, -0.23, 0.78, -0.41, 0.65, -0.32, -0.54, -0.36, 0.92, 0.25, 0.47, -0.1, 0.78, -0.54, 0.63, 0.65, -0.28, 0.25, 0.07, 0.35, 0.62, -0.28, -0.36, -0.54, 0.47, 0.47, 1.43, 0.63, -0.28, 0.03, 0.92, 0.92), .Dim = c(26L, 5L))
Breaks <- c(max(CFh,1.0), 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0,
            -0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8, -0.9, -1.0, min(CFh,-1.0))
h <- hist(CFh, plot=TRUE, breaks=Breaks)

【问题讨论】:

    标签: r statistics histogram distribution


    【解决方案1】:

    从上述解决方案继续, 使用独特的休息时间, 您还可以考虑一种更简单的方法来创建中断作为序列

    Breaks <- unique(c(max(CFh,1.0), seq(1, -1, by=-0.1), min(CFh,-1.0)))
    h <- hist(CFh, plot=TRUE, breaks=Breaks)
    

    【讨论】:

      【解决方案2】:

      您的 Breaks 向量中有重复值。这会导致分箱问题。确保值是唯一的

        h <- hist(CFh, plot=TRUE, breaks=unique(Breaks))
      

      【讨论】:

        猜你喜欢
        • 2014-11-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-11-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多