separate numeric x into bins
Arguments
- x
numeric vector
- bins
bins number, defaults to 10
- lim
the min and max limits of bins, default as
c(min(x), max(x))
- breaks
assign breaks directly and will ignore
bins
andlim
- sort
sort the result tibble
Examples
x <- dplyr::pull(mini_diamond, price, id)
hist_bins(x, bins = 20)
#> # A tibble: 100 × 5
#> id value start end bin
#> <chr> <int> <dbl> <dbl> <int>
#> 1 id-1 3027 2218. 3097. 3
#> 2 id-2 11746 11000. 11879. 13
#> 3 id-3 2029 1340. 2218. 2
#> 4 id-4 9452 9244 10122. 11
#> 5 id-5 2498 2218. 3097. 3
#> 6 id-6 14080 13635 14513. 16
#> 7 id-7 752 462 1340. 1
#> 8 id-8 1029 462 1340. 1
#> 9 id-9 5590 4853 5731. 6
#> 10 id-10 1691 1340. 2218. 2
#> # ℹ 90 more rows