cut_interval_mean()
computes the interval means of a cut
factor, regardless of the their open or closed nature.
Value
A numeric
vector with the interval means.
See also
Other statistical functions:
remove_outliers()
,
std_error()
,
test_outlier()
Examples
cut(1:5, breaks = 3)
#> [1] (0.996,2.33] (0.996,2.33] (2.33,3.67] (3.67,5] (3.67,5]
#> Levels: (0.996,2.33] (2.33,3.67] (3.67,5]
#> [1] (0.996,2.33] (0.996,2.33] (2.33,3.67] (3.67,5] # Expected
#> [5] (3.67,5]
#> Levels: (0.996,2.33] (2.33,3.67] (3.67,5]
cut(1:5, breaks = 3) |> cut_interval_mean()
#> [1] 1.663 1.663 3.000 4.335 4.335
#> [1] 1.663 1.663 3.000 4.335 4.335 # Expected
cut(1:5, breaks = 3) |> cut_interval_mean(names = TRUE)
#> (0.996,2.33] (0.996,2.33] (2.33,3.67] (3.67,5] (3.67,5]
#> 1.663 1.663 3.000 4.335 4.335
#> # Expected
#> (0.996,2.33] (0.996,2.33] (2.33,3.67] (3.67,5] (3.67,5]
#> 1.663 1.663 3.000 4.335 4.335
cut(1:5, breaks = 3) |> cut_interval_mean(round = TRUE)
#> [1] 2 2 3 4 4
#> [1] 2 2 3 4 4 # Expected