library(dplyr)
# Generate data for the example
heartfailure2 <- heartfailure
heartfailure2[sample(seq(NROW(heartfailure2)), 5), "creatinine"] <- NA
# optimal binning
bin <- binning_by(heartfailure2, "death_event", "creatinine")
bin
# summary optimal_bins class
summary(bin)
# performance table
attr(bin, "performance")
# extract binned results
if (!is.null(bin)) {
extract(bin) %>%
head(20)
}
Run the code above in your browser using DataLab