Bin values into buckets and count their occurrences
Description
Usage
<Expr>$hist(
bins = NULL,
...,
bin_count = NULL,
include_category = FALSE,
include_breakpoint = FALSE
)
Arguments
bins
|
Discretizations to make. If NULL (default), we determine
the boundaries based on the data.
|
…
|
These dots are for future extensions and must be empty. |
bin_count
|
If no bins provided, this will be used to determine the distance of the bins. |
include_category
|
Include a column that shows the intervals as categories. |
include_breakpoint
|
Include a column that indicates the upper breakpoint. |
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = c(1, 3, 8, 8, 2, 1, 3))
df$select(pl$col("a")$hist(bins = 1:3))
#> shape: (2, 1)
#> ┌─────┐
#> │ a │
#> │ --- │
#> │ u32 │
#> ╞═════╡
#> │ 3 │
#> │ 2 │
#> └─────┘
#> shape: (2, 1)
#> ┌──────────────────────┐
#> │ a │
#> │ --- │
#> │ struct[3] │
#> ╞══════════════════════╡
#> │ {2.0,"[1.0, 2.0]",3} │
#> │ {3.0,"(2.0, 3.0]",2} │
#> └──────────────────────┘