[R] How to use breaks argument in hist() function correctly?
Stephen Ellison
S@E|||@on @end|ng |rom LGCGroup@com
Wed Sep 18 13:13:59 CEST 2019
> When I had breaks = 18, I get total number of cells as 16, which is
> same when I put breaks = 20
>
> In the 2nd case I was expecting total number of cells (i.e. bars) as
> 20 i.e. if I understand the documentation correctly I should expect
> total number of cells (bars) should be same as breaks argument in
> hist() function.
You do not _quite_ understand the documentation correctly.
?hist says
"In the last three cases the number is a suggestion only; as
the breakpoints will be set to 'pretty' values"
That includes specification of a single number of breaks.
> How to make that happen?
Specify a vector of breaks with 20 intervals (21 values).
For example,
breaks=seq(-4500000, 3500000, length.out=21)
This gives a bin width of 4e5.
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
More information about the R-help
mailing list