We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
draft:
rnet_merge_str = function(rnet_x, rnet_y, dist = 5, funs = NULL, crs = geo_select_aeq(rnet_x), ...) { # Identify string columns in rnet_y string_cols = sapply(rnet_y, is.character) # Initialize funs for string columns if it is NULL if (is.null(funs)) { funs = list() string_col_names = names(rnet_y)[string_cols] for (col in string_col_names) { # Default behavior for string columns: concatenating unique values funs[[col]] = function(x) paste(unique(x), collapse = ", ") } } # Join the route networks using rnet_join rnetj = rnet_join(rnet_x, rnet_y, dist = dist, crs = crs, ...) rnetj_df = sf::st_drop_geometry(rnetj) # Apply functions to string columns as specified in funs res_list = lapply(names(funs), function(nm) { if (string_cols[nm]) { fn = funs[[nm]] res = rnetj_df %>% dplyr::group_by_at(1) %>% dplyr::summarise(dplyr::across(dplyr::all_of(nm), fn)) names(res)[2] = nm return(res) } NULL # Return NULL for non-string columns }) res_list = Filter(Negate(is.null), res_list) # Remove NULL elements # Combine the results into a single data frame res_df = dplyr::bind_cols(res_list) # Join the results with the original rnet_x geometry res_sf = dplyr::left_join(rnet_x, res_df) return(res_sf) } # Example usage of the function funs = list(road_name = function(x) paste(unique(x), collapse = ", ")) rnet_merged = rnet_merge(rnet_x, rnet_y, funs = funs)
The text was updated successfully, but these errors were encountered:
Thanks for this @wangzhao0217 I plan to give it a test...
Sorry, something went wrong.
Demonstrate issue with #554
3371d91
wangzhao0217
Successfully merging a pull request may close this issue.
draft:
The text was updated successfully, but these errors were encountered: