How do I inner join on range of values, using between()?

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?

Join specifications — join_by • dplyr (tidyverse.org)

1 Like

you can do it with plain tidyverse, but its not implemented in tidytable ( Implement join_by() · Issue #222 · markfairbanks/tidytable (github.com))

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.