Binning launch variables
bin_rates <- function(sc_ip, LA_breaks, LS_breaks) {
Total_BIP <- nrow(sc_ip)
sc_ip |>
mutate(
LS = cut(launch_speed, breaks = LS_breaks),
LA = cut(launch_angle, breaks = LA_breaks)
) |>
filter(!is.na(LA), !is.na(LS)) |>
group_by(LA, LS) |>
summarize(
BIP = n(),
HR = sum(HR),
.groups = "drop"
) |>
mutate(
BIP_Rate = 100 * BIP / Total_BIP,
HR_Rate = 100 * HR / BIP
)
}