df_bins = tidytable(
BIN = c(1, 2, 3),
RANGE_MIN = c(0, 0.01, 0.02),
RANGE_MAX = c(0.009, 0.019, 0.03)
)
df_values = tidytable(
VALUES = c(0.005, 0.004, 0.017)
)
# df_values |> mutate(BIN = ???)
# df_values |> inner_join(???)
With the assumption that there are many of bins and many of rows, what I would like to do is have a new column BIN
be in df_values
that assigns the appropriate bin. I found between()
function, but was unable to find a way to assign it. If there were only three bins, if_else()
statements would be doable, but since there are so many, I thought there should be a way to do it programmatically using dplyr
functions.
Am I right that between()
would be useful here?