Created
February 28, 2019 20:43
-
-
Save rkingdc/e5bca600d06cbb07463b7ac54a5ae043 to your computer and use it in GitHub Desktop.
Binning Columns in Remote Tables" dplyr join function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db_dplyr_join_fn <- function(data, tbl_cuts, column_to_cut="column_to_cut"){ | |
bin_choices <- data %>% | |
select(., id, k_dummy, !!rlang::sym(column_to_cut)) %>% | |
left_join(., tbl_cuts, by = 'k_dummy') %>% | |
filter(., cut >= !!rlang::sym(column_to_cut)) %>% | |
group_by(., id) %>% | |
summarise(., cut_ = min(cut, na.rm = TRUE)) | |
return(dplyr::compute(dplyr::left_join(data, bin_choices, by = 'id'))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment