Skip to contents

Useful before summarizing and plotting.

Usage

bin_variable(x, bin.width)

Arguments

x

A vector

bin.width

The bin width. E.g., 20 will make each bin a maximum of 20 units wide

Value

A data frame

Examples

x<-c(seq(1,23,1),seq(5,12,1))
bin_variable(x,5)
#>         grp
#> 1    1 to 5
#> 2    1 to 5
#> 3    1 to 5
#> 4    1 to 5
#> 5    1 to 5
#> 6   6 to 10
#> 7   6 to 10
#> 8   6 to 10
#> 9   6 to 10
#> 10  6 to 10
#> 11 11 to 15
#> 12 11 to 15
#> 13 11 to 15
#> 14 11 to 15
#> 15 11 to 15
#> 16 16 to 20
#> 17 16 to 20
#> 18 16 to 20
#> 19 16 to 20
#> 20 16 to 20
#> 21 21 to 23
#> 22 21 to 23
#> 23 21 to 23
#> 24   1 to 5
#> 25  6 to 10
#> 26  6 to 10
#> 27  6 to 10
#> 28  6 to 10
#> 29  6 to 10
#> 30 11 to 15
#> 31 11 to 15