R: Control number of histogram bins

后端 未结 1 676
时光取名叫无心
时光取名叫无心 2021-01-27 23:20

I am using the hist-function to analyze some data I generated. For an analysis-assay I would like to precisely control the number of histogram bins.

I know the \"break-a

1条回答
  •  再見小時候
    2021-01-27 23:33

    From ?hist, there are several options for controlling the bins through the breaks argument.

    breaks one of:

    a vector giving the breakpoints between histogram cells,

    a function to compute the vector of breakpoints,

    a single number giving the number of cells for the histogram,

    a character string naming an algorithm to compute the number of cells (see ‘Details’),

    a function to compute the number of cells.

    In the last three cases the number is a suggestion only; the breakpoints will be set to pretty values. If breaks is a function, the x vector is supplied to it as the only argument.

    For the greatest precision, you have to set the breakpoints exactly, either by supplying a vector of breakpoints, or a function to compute them. You need to cover the entire range of x with your breakpoints and there will be 1 more breakpoint than bins (i.e. no_bins + 1 = no_breaks).

    0 讨论(0)
提交回复
热议问题