If the number of unique numbers is five or fewer, then they will simply be converted to factors in order, otherwise, they will be passed to cut and pretty, preserving the lowest value.
fac_from_num(x)a factor
fac_from_num(1:100)
#> [1] [0,20] [0,20] [0,20] [0,20] [0,20] [0,20] [0,20] [0,20]
#> [9] [0,20] [0,20] [0,20] [0,20] [0,20] [0,20] [0,20] [0,20]
#> [17] [0,20] [0,20] [0,20] [0,20] (20,40] (20,40] (20,40] (20,40]
#> [25] (20,40] (20,40] (20,40] (20,40] (20,40] (20,40] (20,40] (20,40]
#> [33] (20,40] (20,40] (20,40] (20,40] (20,40] (20,40] (20,40] (20,40]
#> [41] (40,60] (40,60] (40,60] (40,60] (40,60] (40,60] (40,60] (40,60]
#> [49] (40,60] (40,60] (40,60] (40,60] (40,60] (40,60] (40,60] (40,60]
#> [57] (40,60] (40,60] (40,60] (40,60] (60,80] (60,80] (60,80] (60,80]
#> [65] (60,80] (60,80] (60,80] (60,80] (60,80] (60,80] (60,80] (60,80]
#> [73] (60,80] (60,80] (60,80] (60,80] (60,80] (60,80] (60,80] (60,80]
#> [81] (80,100] (80,100] (80,100] (80,100] (80,100] (80,100] (80,100] (80,100]
#> [89] (80,100] (80,100] (80,100] (80,100] (80,100] (80,100] (80,100] (80,100]
#> [97] (80,100] (80,100] (80,100] (80,100]
#> Levels: [0,20] (20,40] (40,60] (60,80] (80,100]
fac_from_num(sample(100, 5))
#> [1] 73 69 5 24 79
#> Levels: 5 24 69 73 79