2017-06-04 72 views
0

我有一個值列表。有了,我其實不是繪製直方圖,但回到休息和計數的列表:R直方圖,通過y值找到x值的範圍(頻率)

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

現在我試圖讓x值的範圍,即採取連成一個垃圾桶。我只對最高頻率的垃圾箱感興趣。我因此創建

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

現在我正在使用該函數返回bin的中間值作爲x值與最大值。頻率:

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

但是,如何獲得那一個bin的全部範圍?

回答

0
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的開始和結束值。