【问题标题】:R histogram, find range of x-values by y-value (frequencies)R 直方图,通过 y 值(频率)查找 x 值的范围
【发布时间】:2017-06-04 22:45:02
【问题描述】:

我有一个值列表。这样,我实际上不是在绘制直方图,而是返回一个中断和计数列表:

hist(loc$position, breaks=100000, plot=F)

现在我正在尝试获取 x 值的范围,将它们一起放入一个 bin 中。我只对频率最高的垃圾箱感兴趣。因此我创造了

x <- hist(loc$position, breaks=100000, plot=F)

现在我使用它来将 bin 的中间作为 x 值返回,最大值为 x 值。频率:

x$mids[which.max(list_histo$counts)]

但是我怎样才能得到那个箱子的全部范围呢?

【问题讨论】:

    标签: r histogram


    【解决方案1】:
    hist_data <- hist(loc$position, breaks=100000, plot=F)
    
    c(hist_data$breaks[which.max(hist_data$counts)],
      hist_data$breaks[which.max(hist_data$counts)+1])
    

    这样您将获得一个向量,其中包含大多数元素的 bin 的开始值和结束值。

    【讨论】:

      猜你喜欢
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-09
      • 1970-01-01
      • 1970-01-01
      • 2011-12-06
      • 1970-01-01
      相关资源
      最近更新 更多