It took me a minute to realize the behavior of step_cut is different than that of cut.
The functionality of step_cut expects explicit breaks whereas cut will generate intervals when a single integer value is provided in breaks.
library('dplyr')
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library('tidymodels')
tidymodels_prefer()
Created on 2024-11-19 with [reprex v2.1.1](https://reprex.tidyverse.org/)
Perhaps an option for n_breaks to the step_cut option, could also exist for vectors or named lists and just apply the vector, named list to the list of variables
# psuedo code for step_cut_n_breaks
step_cut_n_breaks <- function(var, n_breaks, include_outside_range) {
var_min <- min(var)
var_max <- max(var)
diff <- (var_max - var_min)/n_cut_breaks
res_seq <- seq(
var_min,
var_max,
by = diff
)
res_seq <- res_seq[-1]
res_seq <- res_seq[-length(resl_seq)]
# Once the ranges have been computed you could still use the existing step_cut functionality:
step_cut(force_cuts, breaks = res_seq, include_outside_range = include_outside_range)
}
feature-request
It took me a minute to realize the behavior of
step_cut
is different than that ofcut
.The functionality of
step_cut
expects explicit breaks whereascut
will generate intervals when a single integer value is provided inbreaks
.Perhaps an option for
n_breaks
to thestep_cut
option, could also exist for vectors or named lists and just apply the vector, named list to the list of variables