R中的直方图函数-中断参数不起作用

ina*_*lei 5 plot r histogram

我喜欢为每行创建带有定义中断的直方图对象:

Hist <- list()
for (i in 1:10) { 
   Hist[[i]] <- hist(data[i,],breaks=25)
}
Run Code Online (Sandbox Code Playgroud)

但是我的休息要求与输出中的休息次数之间存在差异。而且直方图中的中断次数也不同。

有什么原因吗?

csg*_*pie 6

要获得一致breaks,请指定一个向量。不是整数,正如您所料!

是的,这是有原因的 ;) 从直方图帮助页面?hist

`breaks` can be one of:
  
  1. a vector giving the breakpoints between histogram cells,
  2. a function to compute the vector of breakpoints,
  3. a single number giving the number of cells for the histogram,
  4. a character string naming an algorithm to compute the number of cells (see ‘Details’),
  5. a function to compute the number of cells.
Run Code Online (Sandbox Code Playgroud)

在案例 3、4、5 中,数字只是一个建议;断点将设置为漂亮的值。如果breaks是一个函数,则将x向量作为唯一参数提供给它。


请注意我以粗体突出显示的部分。