From 2653c3930dadca757dc94da3d60c397ac13070d9 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Sun, 18 Jan 2026 18:52:54 -0500 Subject: [PATCH 01/41] Add asn_tilegrid() --- .Rbuildignore | 1 + DESCRIPTION | 6 + NAMESPACE | 5 + R/asn_tilegrid.R | 557 ++++++++++++++++++++++++++++++++++++++ R/check_all.R | 204 ++++---------- R/data.R | 53 ++++ _pkgdown.yml | 2 + data-raw/DATASET.R | 205 ++++++++++++++ data/board_prep_df.rda | Bin 0 -> 1187 bytes data/grid_df.rda | Bin 0 -> 404 bytes data/neph_per_100K_df.rda | Bin 0 -> 893 bytes man/asn_tilegrid.Rd | 61 +++++ man/board_prep_df.Rd | 35 +++ man/check_all.Rd | 34 +-- man/grid_df.Rd | 29 ++ man/neph_per_100K_df.Rd | 29 ++ 16 files changed, 1047 insertions(+), 174 deletions(-) create mode 100644 R/asn_tilegrid.R create mode 100644 R/data.R create mode 100644 data-raw/DATASET.R create mode 100644 data/board_prep_df.rda create mode 100644 data/grid_df.rda create mode 100644 data/neph_per_100K_df.rda create mode 100644 man/asn_tilegrid.Rd create mode 100644 man/board_prep_df.Rd create mode 100644 man/grid_df.Rd create mode 100644 man/neph_per_100K_df.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 446bfca..61f8e31 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,3 +6,4 @@ ^docs$ ^pkgdown$ ^\.github$ +^data-raw$ diff --git a/DESCRIPTION b/DESCRIPTION index 62e1156..04c3806 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,12 +19,15 @@ Imports: ggplot2, ggtext, glue, + grid, highcharter, lifecycle, methods, + patchwork, rlang, scales, tidyr, + tidyselect, vctrs URL: https://github.com/ASNDataAnalytics/asn, https://asndataanalytics.github.io/asn/ @@ -32,3 +35,6 @@ BugReports: https://github.com/ASNDataAnalytics/asn/issues Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 +Depends: + R (>= 4.1.0) +LazyData: true diff --git a/NAMESPACE b/NAMESPACE index bda4714..1c78aca 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,6 +13,7 @@ export(asn_secondary) export(asn_secondary_blue) export(asn_spring) export(asn_theme) +export(asn_tilegrid) export(check_all) export(get_labels) export(get_labs) @@ -31,10 +32,14 @@ export(theme_asn_dark) import(dplyr) import(forcats) import(ggplot2) +import(glue) +import(grid) import(highcharter) +import(patchwork) import(rlang) import(scales) import(tidyr) +import(tidyselect) importFrom(grDevices,colorRampPalette) importFrom(lifecycle,deprecated) importFrom(methods,setOldClass) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R new file mode 100644 index 0000000..6437d22 --- /dev/null +++ b/R/asn_tilegrid.R @@ -0,0 +1,557 @@ +#' Create a U.S. Tilegrid Choropleth Map in ggplot2 in style of The Economist +#' @import dplyr +#' @import ggplot2 +#' @import glue +#' @import patchwork +#' @import grid +#' @param data A data frame, comprising a column with 2-letter USPS state abbreviations and a column with a +#' numeric variable to be visualized in a tilegrid choropleth map. +#' @param data_source Source of the numeric data visualized in the choropleth. +#' @param plot_title Plot title. +#' @param state_column Column containing 2-letter USPS state abbreviations. +#' @param numeric_column Column containing numeric data being visualized in choropleth. +#' @param plot_panel_color Background color for plot. +#' @param palette Vector of hex colors mapping numeric column to choropleth map fill color. +#' @param breaks Numeric vector of breaks corresponding to colors in the color palette mapping to the numeric column. +#' @param zero_color Optional hex color to indicate states with a 0 numeric value. +#' @param na_color Optional hex color to indicate states with missing values. +#' +#' @returns ggplot2 object +#' +#' @export +#' @examples +#' asn_tilegrid( +#' data = neph_per_100K_df, +#' data_source = "AMA PPD and U.S. Census Bureau.", +#' plot_title = "Ratio of Nephrologists per 100K Adult Population", +#' state_column = "MailState", +#' numeric_column = neph_per_100k, +#' plot_panel_color = "#ffffff", +#' palette = c("#f0f8ff", "#a0bdd8", "#5081b2", "#00468b"), +#' breaks = c(2.21, 3.1, 4, 5.6), +#' zero_color = NULL, +#' na_color = "#EEECE6" +#' ) + +asn_tilegrid <- function( + data = df, + data_source = "Source", + plot_title = "Plot Title", + state_column = "state_column_name", + numeric_column = n, + plot_panel_color = "#ffffff", + palette = c("#FCC8B4", "#FAAA90", "#F58469", "#EF1B26"), # Ascending Order + breaks = c(1, 2, 6, 11), # Ascending Order + zero_color = NULL, + na_color = NULL + ) { + + ## 01 Ensure Palette Length and Breaks Are Same Length ---- + + pal <- palette + + pal_length <- length(pal) + + breaks_length <- length(breaks) + + if (pal_length != breaks_length) { + stop("The palette and break lengths must be the same.") + } + + if (pal_length > 5) { + stop("The maximum number of bins and colors is 5.") + } + + ## 02 Build Tile Grid Choropleth ---- + + ## 02.01 If NA ---- + + if(is.null(zero_color) & !is.null(na_color)) { + choropleth <- + grid_df |> + dplyr::left_join( + data, + by = c("State" = {{ state_column }}) + ) |> + dplyr::mutate( + fill_color = dplyr::case_when( + is.na({{ numeric_column }}) ~ na_color, + dplyr::between({{ numeric_column }}, 0, breaks[1]) ~ pal[1], + dplyr::between({{ numeric_column }}, breaks[1], breaks[2]) ~ pal[2], + dplyr::between({{ numeric_column }}, breaks[2], breaks[3]) ~ pal[3], + dplyr::between({{ numeric_column }}, breaks[3], breaks[4]) ~ pal[4] + ) + ) |> + dplyr::mutate( + text_color = dplyr::if_else( + fill_color == pal[4], + "#ffffff", + "#000000" + ) + ) |> + ggplot2::ggplot( + ggplot2::aes( + x = x, + y = y + ) + ) + + ggplot2::geom_tile( + ggplot2::aes( + fill = fill_color + ), + color = "#000", + linewidth = 0.2 + ) + + ggplot2::scale_fill_identity() + + ggplot2::theme_void() + + ggplot2::coord_equal() + + ggplot2::geom_text( + ggplot2::aes( + label = State, + color = text_color + ), + family = "Gotham", + size = 3.4 + ) + + ggplot2::scale_color_identity() + + ggplot2::labs( + caption = glue::glue("Source: {data_source}") + ) + + ggplot2::theme( + plot.caption = ggplot2::element_text( + hjust = 0.06, + family = "Gotham", + color = "#5c5c5c" + ), + plot.caption.position = "plot", + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + + } else if(!is.null(zero_color) & is.null(na_color)) { + + ## 02.02 If Zero ---- + + choropleth <- + grid_df |> + dplyr::left_join( + data, + by = c("State" = {{ state_column }}) + ) |> + dplyr::mutate( + fill_color = dplyr::case_when( + {{ numeric_column }} == 0 ~ zero_color, + dplyr::between({{ numeric_column }}, 0.01, breaks[1]) ~ pal[1], + dplyr::between({{ numeric_column }}, breaks[1], breaks[2]) ~ pal[2], + dplyr::between({{ numeric_column }}, breaks[2], breaks[3]) ~ pal[3], + dplyr::between({{ numeric_column }}, breaks[3], breaks[4]) ~ pal[4] + ) + ) |> + dplyr::mutate( + text_color = dplyr::if_else( + fill_color == pal[4], + "#ffffff", + "#000000" + ) + ) |> + ggplot2::ggplot( + ggplot2::aes( + x = x, + y = y + ) + ) + + ggplot2::geom_tile( + ggplot2::aes( + fill = fill_color + ), + color = "#000", + linewidth = 0.2 + ) + + ggplot2::scale_fill_identity() + + ggplot2::theme_void() + + ggplot2::coord_equal() + + ggplot2::geom_text( + ggplot2::aes( + label = State, + color = text_color + ), + family = "Gotham", + size = 3.4 + ) + + ggplot2::scale_color_identity() + + ggplot2::labs( + caption = glue::glue("Source: {data_source}") + ) + + ggplot2::theme( + plot.caption = ggplot2::element_text( + hjust = 0.06, + family = "Gotham", + color = "#5c5c5c" + ), + plot.caption.position = "plot", + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + + + } else if(is.null(na_color) & is.null(zero_color)){ + + ## 02.03 If Neither NA nor Zero + + choropleth <- + grid_df |> + dplyr::left_join( + data, + by = c("State" = {{ state_column }}) + ) |> + dplyr::mutate( + fill_color = dplyr::case_when( + dplyr::between({{ numeric_column }}, 0, breaks[1]) ~ pal[1], + dplyr::between({{ numeric_column }}, breaks[1], breaks[2]) ~ pal[2], + dplyr::between({{ numeric_column }}, breaks[2], breaks[3]) ~ pal[3], + dplyr::between({{ numeric_column }}, breaks[3], breaks[4]) ~ pal[4] + ) + ) |> + dplyr::mutate( + text_color = dplyr::if_else( + fill_color == pal[4], + "#ffffff", + "#000000" + ) + ) |> + ggplot2::ggplot( + ggplot2::aes( + x = x, + y = y + ) + ) + + ggplot2::geom_tile( + ggplot2::aes( + fill = fill_color + ), + color = "#000", + linewidth = 0.2 + ) + + ggplot2::scale_fill_identity() + + ggplot2::theme_void() + + ggplot2::coord_equal() + + ggplot2::geom_text( + ggplot2::aes( + label = State, + color = text_color + ), + family = "Gotham", + size = 3.4 + ) + + ggplot2::scale_color_identity() + + ggplot2::labs( + caption = glue::glue("Source: {data_source}") + ) + + ggplot2::theme( + plot.caption = ggplot2::element_text( + hjust = 0.06, + family = "Gotham", + color = "#5c5c5c" + ), + plot.caption.position = "plot", + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + } + + ## 03 Build guide_legend() Scales ---- + + scale_df <- + data.frame( + x = seq(10, 40, 10), + y = rep(0.1, 4), + fill_color = pal + ) + + top_legend <- + ggplot2::ggplot( + scale_df, + ggplot2::aes( + x = x, + y = y + ) + ) + + ggplot2::geom_tile( + color = "#000000", + ggplot2::aes( + fill = fill_color + ), + linewidth = 0.4 + ) + + ggplot2::scale_fill_identity() + + ggplot2::theme_void( + base_family = "Gotham" + ) + + ggplot2::scale_x_continuous( + breaks = seq( + 15, + 45, + 10 + ), + labels = breaks |> + as.character() + ) + + ggplot2::theme( + axis.text.x.bottom = ggplot2::element_text( + vjust = 0.5, + size = 10 + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + + ## 04 Determine if Zero or NA Color Guide Needed + + if(is.null(zero_color) & !is.null(na_color)) { + + zero_na_df <- + data.frame( + x = 1, + y = 0.1, + fill_color = na_color + ) + + zero_na_legend <- + ggplot2::ggplot( + zero_na_df, + ggplot2::aes( + x = x, + y = y + ) + ) + + ggplot2::geom_tile( + color = "#000000", + ggplot2::aes( + fill = fill_color + ), + linewidth = 0.4 + ) + + ggplot2::scale_fill_identity() + + ggplot2::theme_void( + base_family = "Gotham" + ) + + ggplot2::scale_x_continuous( + breaks = 1, + labels = "NA" + ) + + ggplot2::theme( + axis.text.x.bottom = ggplot2::element_text( + vjust = 0.5, + size = 10 + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + + ggplot2::coord_fixed(ratio = 1) + + } else if(!is.null(zero_color) & is.null(na_color)) { + + zero_na_df <- + data.frame( + x = 1, + y = 0.1, + fill_color = zero_color + ) + + zero_na_legend <- + ggplot2::ggplot( + zero_na_df, + ggplot2::aes( + x = x, + y = y + ) + ) + + ggplot2::geom_tile( + color = "#000000", + ggplot2::aes( + fill = fill_color + ), + linewidth = 0.4 + ) + + ggplot2::scale_fill_identity() + + ggplot2::theme_void( + base_family = "Gotham" + ) + + ggplot2::scale_x_continuous( + breaks = 1, + labels = "0" + ) + + ggplot2::theme( + axis.text.x.bottom = ggplot2::element_text( + vjust = 0.5, + size = 10 + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + + ggplot2::coord_fixed(ratio = 1) + } + + zero_na_df <- + data.frame( + x = 1, + y = 0.1, + fill_color = na_color + ) + + zero_na_legend <- + ggplot2::ggplot( + zero_na_df, + ggplot2::aes( + x = x, + y = y + ) + ) + + ggplot2::geom_tile( + color = "#000000", + ggplot2::aes( + fill = fill_color + ), + linewidth = 0.4 + ) + + ggplot2::scale_fill_identity() + + ggplot2::theme_void( + base_family = "Gotham" + ) + + ggplot2::scale_x_continuous( + breaks = 1, + labels = "NA" + ) + + ggplot2::theme( + axis.text.x.bottom = ggplot2::element_text( + vjust = 0.5, + size = 10 + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + + ggplot2::coord_fixed(ratio = 1) + + ## 04 Assemble Plot ---- + + ## 04.01 No Zero Color or NA Color + + if (is.null(zero_color) & is.null(na_color)) { + ( + ( + patchwork::plot_spacer() + + ggplot2::theme( + plot.margin = grid::unit(c(0, 0, 0, 30), "pt") + ) + + top_legend + + patchwork::plot_spacer() + ) + + patchwork::plot_layout(widths = c(2, 5, 2), nrow = 1) + ) / + choropleth + + patchwork::plot_layout( + heights = c(0.05, 1) + ) + + patchwork::plot_annotation( + title = plot_title + ) & + ggplot2::theme( + plot.title = ggtext::element_textbox_simple( + size = 11, + family = "Gotham", + hjust = 0.25, + margin = ggplot2::margin(0, 0, 5, 0, unit = "pt") + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + + } else { + + ## 04.02 Add Zero or NA Color Legend + + ( + ( + patchwork::plot_spacer() + + zero_na_legend + + ggplot2::theme( + plot.margin = grid::unit(c(0, 0, 0, 30), "pt") + ) + + top_legend + + patchwork::plot_spacer() + ) + + patchwork::plot_layout(widths = c(0.3, 1, 5, 1.4), nrow = 1) + ) / + choropleth + + patchwork::plot_layout( + heights = c(0.05, 1) + ) + + patchwork::plot_annotation( + title = plot_title + ) & + ggplot2::theme( + plot.title = ggtext::element_textbox_simple( + size = 11, + family = "Gotham", + hjust = 0.25, + margin = ggplot2::margin(0, 0, 5, 0, unit = "pt") + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) + ) + } +} diff --git a/R/check_all.R b/R/check_all.R index 05a262e..747add4 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -1,8 +1,8 @@ #' Count number of unique responses to 'Select All'/'Check All' survey questions #' @import dplyr #' @import rlang -#' @import forcats #' @import tidyr +#' @import tidyselect #' @param data A data frame, typically results from a Qualtrics survey, where responses to #' 'Select All'/'Check All' questions are recorded in consecutive columns named using the #' format: `Question-Number_Response-Option-Number`. For example, if Question 2 @@ -19,167 +19,77 @@ #' @export #' #' @examples -#' -#' # Toy Dataset -#' mouse_cheese_df <- -#' dplyr::tribble( -#' ~Q1, ~Q2_1, ~Q2_2, ~Q2_3, ~Q2_4, ~Q2_TEXT, -#' "Country", NA, NA, NA, "Colby", "Brie", -#' "City", NA, "Gruyere", NA, NA, "", -#' "City", NA, NA, "Swiss", NA, "Parmesan", -#' "City", NA, NA, NA, NA, "", -#' "Country", "Cheddar", NA, NA, "Colby", "", -#' "City", "Cheddar", NA, NA, "Colby", "", -#' "Country", "Cheddar", "Gruyere", NA, "Colby", "", -#' "City", NA, "Gruyere", NA, NA, "", -#' "City", NA, "Gruyere", NA, NA, "", -#' "City", NA, NA, "Swiss", NA, "Mozzarella", -#' "Country", "Cheddar", NA, NA, "Colby", "" -#' ) |> -#' dplyr::mutate( -#' dplyr::across(dplyr::everything(), as.factor) -#' ) #' # Grouped Results #' check_all( -#' data = mouse_cheese_df, -#' group_var = Q1, -#' column_prefix = "Q2", -#' free_text_var_suffix = "_TEXT" +#' data = board_prep_df, +#' group_var = q6, +#' column_prefix = "q65", +#' free_text_var_suffix = "_6_text" #' ) #' #' # Ungrouped Results #' check_all( -#' data = mouse_cheese_df, -#' column_prefix = "Q2", -#' free_text_var_suffix = "_TEXT" +#' data = board_prep_df, +#' column_prefix = "q65", +#' free_text_var_suffix = "_6_text" #' ) + check_all <- function( - data, - group_var = NULL, - column_prefix, - free_text_var_suffix = "_TEXT" + data, + group_var = NULL, + column_prefix, + free_text_var_suffix = "_TEXT" ) { - + group_var_expr <- rlang::enquo(group_var) - free_text_column <- paste0(column_prefix, free_text_var_suffix) - - num_col <- data |> - dplyr::select( - dplyr::all_of( - dplyr::contains(column_prefix) - ) - ) |> - # Omit Free Text Responses - dplyr::select( - !free_text_column - ) |> - ncol() - - if(rlang::quo_is_null(group_var_expr)) { - - ret <- data |> - dplyr::select( - dplyr::all_of( - dplyr::contains(column_prefix) - ) - ) |> - # Omit Free Text Responses - dplyr::select( - !free_text_column - ) |> - dplyr::rowwise() |> - dplyr::mutate( - all_miss = sum( - is.na( - dplyr::c_across( - dplyr::all_of(dplyr::contains(column_prefix)) - ) - ) - ) - ) |> - dplyr::ungroup() |> - dplyr::filter(all_miss < num_col) |> - dplyr::reframe( - dplyr::across( - dplyr::all_of( - dplyr::contains(column_prefix) - ), - forcats::fct_count - ) - ) |> + has_free_text <- free_text_column %in% names(data) + + # Select relevant columns + if (rlang::quo_is_null(group_var_expr)) { + if (has_free_text) { + data_filtered <- + data |> + dplyr::select(tidyselect::contains(column_prefix)) |> + dplyr::select(!tidyselect::all_of(free_text_column)) + } else { + data_filtered <- + data |> + dplyr::select(tidyselect::contains(column_prefix)) + } + } else { + if (has_free_text) { + data_filtered <- + data |> + dplyr::select(!!group_var_expr, tidyselect::contains(column_prefix)) |> + dplyr::select(!tidyselect::all_of(free_text_column)) + } else { + data_filtered <- + data |> + dplyr::select(!!group_var_expr, tidyselect::contains(column_prefix)) + } + } + + # Pivot and count + if (rlang::quo_is_null(group_var_expr)) { + data_filtered |> tidyr::pivot_longer( - names_to = column_prefix, - values_to = "Number", - cols = dplyr::everything() + cols = everything(), + names_to = "question", + values_to = "value" ) |> - dplyr::select(-column_prefix) |> - dplyr::mutate( - column_prefix = Number$f, - N = Number$n - ) |> - dplyr::select( - Variable = column_prefix, - N - ) |> - tidyr::drop_na() |> - dplyr::distinct() - - + dplyr::filter(!is.na(value)) |> + dplyr::count(value, name = "N") |> + dplyr::rename(Variable = value) } else { - - ret <- data |> - dplyr::select( - !! group_var_expr, - dplyr::all_of( - dplyr::contains(column_prefix) - ) - ) |> - # Omit Free Text Responses - dplyr::select( - !free_text_column - ) |> - dplyr::rowwise() |> - dplyr::mutate( - all_miss = sum( - is.na( - dplyr::c_across( - dplyr::all_of(contains(column_prefix)) - ) - ) - ) - ) |> - dplyr::ungroup() |> - dplyr::filter(all_miss < num_col) |> - dplyr::group_by(!! group_var_expr) |> - dplyr::reframe( - dplyr::across( - dplyr::all_of( - dplyr::contains(column_prefix) - ), - forcats::fct_count - ) - ) |> - dplyr::ungroup() |> + data_filtered |> tidyr::pivot_longer( - names_to = column_prefix, - values_to = "Number", - cols = - !! group_var_expr - ) |> - dplyr::select(-column_prefix) |> - dplyr::mutate( - column_prefix = Number$f, - N = Number$n + cols = -!!group_var_expr, + names_to = "question", + values_to = "value" ) |> - dplyr::select( - !! group_var_expr, - Variable = column_prefix, - N - ) |> - tidyr::drop_na() |> - dplyr::distinct() + dplyr::filter(!is.na(value)) |> + dplyr::count(!!group_var_expr, value, name = "N") |> + dplyr::rename(Variable = value) } - - ret - } diff --git a/R/data.R b/R/data.R new file mode 100644 index 0000000..bcb8f50 --- /dev/null +++ b/R/data.R @@ -0,0 +1,53 @@ +#' Board Prep Resources +#' +#' Resources used by nephrology fellows in preparation for initial board certication in +#' nephrology. This is a synthesized data set generated based on proportions of actual responses to +#' measures in the 2025 ASN Nephrology Fellow Survey. +#' +#' @format A data frame with 8 columns +#' 1. `q6`: Repondent medical school location, either "United States" or "Other country". +#' 2. `q65_1`: ASN Kidney Self-Assessment Program (KSAP) selected as a used resource ( = "No"). +#' 3. `q65_2`: ASN Nephrology Self-Assessment Program (NephSAP) selected as a used resource ( = "No"). +#' 4. `q65_3`: ASN Board Review Course & Update selected as a used resource ( = "No"). +#' 5. `q65_4`: Oakstone/Brigham Intensive Review of Nephrology Course ( = "No"). +#' 6. `q65_5`: Other board review course ( = "No"). +#' 7. `q65_6`: Other resource(s) (please specify) ( = "No"). +#' 8. `q65_6_text`: Free text response describing other resource(s) used. +#' +#' @source +#' +#' @examples +#' board_prep_df +#' +"board_prep_df" + +#' Nephrologists per 100K U.S. Population by State +#' +#' Ratio of practicing nephrologists per 100K adult population per state and District of +#' Columbia in 2023. Nephrologist counts aggregated from the American Medical Assosciation +#' Physician Professional Database. U.S. adult population extracted from the U.S. Census Bureau. +#' +#' @format A data frame with 2 columns: +#' 1. `MailState`: USPS codes for U.S. states and the District of Columbia. +#' 2. `neph_per_100k`: Ratio of practicing nephrologists per 100K adult population in state/DC. +#' @source +#' +#' @examples +#' neph_per_100K_df +#' +"neph_per_100K_df" + +#' Grid Data Frame for asn_tilegrid() +#' +#' Data frame of The Economist's 8 x 11 rectangular tile grid for the asn_tilegrid() function, adapted from the tilegrid +#' choropleth designed by The Economist Data Team. +#' +#' @format A data frame with 6 columns: +#' 1. `State`: USPS codes for U.S. states and the District of Columbia. +#' 2. `x`: Corresponding x coordinate for tilegrid. +#' 3. `y`: Corresponding y coordinate for tilegrid. +#' @source +#' @examples +#' grid_df +#' +"grid_df" \ No newline at end of file diff --git a/_pkgdown.yml b/_pkgdown.yml index 3db95db..5d9d2ba 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,6 @@ url: https://asndataanalytics.github.io/asn/ template: bootstrap: 5 + light-switch: true + bootswatch: litera diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R new file mode 100644 index 0000000..3f63e3f --- /dev/null +++ b/data-raw/DATASET.R @@ -0,0 +1,205 @@ +## 1. Synthesized Survey Data Based on the 2025 ASN Nephrology Fellow Survey + +set.seed(20260116) + +board_prep_df <- + data.frame( + q6 = sample( + c("United States", "Other country"), + size = 400, + prob = c(0.42, 0.58), + replace = TRUE + ), + q65_1 = sample( + c("ASN Kidney Self-Assessment Program (KSAP)", NA_character_), + size = 400, + prob = c(0.484, 1 - 0.484), + replace = TRUE + ), + q65_2 = sample( + c("ASN Nephrology Self-Assessment Program (NephSAP)", NA_character_), + size = 400, + prob = c(0.274, 1 - 0.274), + replace = TRUE + ), + q65_3 = sample( + c("ASN Board Review Course & Update", NA_character_), + size = 400, + prob = c(0.381, 1 - 0.381), + replace = TRUE + ), + q65_4 = sample( + c("Oakstone/Brigham Intensive Review of Nephrology Course", NA_character_), + size = 400, + prob = c(0.0442, 1 - 0.0442), + replace = TRUE + ), + q65_5 = sample( + c("Other board review course", NA_character_), + size = 400, + prob = c(0.0324, 1 - 0.0324), + replace = TRUE + ), + q65_6 = sample( + c("Other resource(s) (please specify)", NA_character_), + size = 400, + prob = c(0.0324, 1 - 0.0324), + replace = TRUE + ), + q65_6_text = c( + rep(NA_character_, 235), + "Textbooks", + rep(NA_character_, 14), + "Washington Manual Nephrology Subspecialty Consult", + rep(NA_character_, 50), + "Board Vitals for Nephrology", + rep(NA_character_, 56), + "Institution Materials", + rep(NA_character_, 5), + "Brcu", + rep(NA_character_, 23), + "uptodate", + rep(NA_character_, 10), + "Comprehensive" + ) + ) + +usethis::use_data(board_prep_df, overwrite = TRUE) + +## 2. Ratio of Nephrologists per 100K U.S. Population by State + +neph_per_100K_df <- + tibble::tribble( + ~MailState, ~neph_per_100k, + "ND", 2.66143841875072, + "VT", 2.6205935490236, + "OK", 2.04238213609549, + "MI", 2.81652259426326, + "NM", 2.6400598916444, + "IA", 1.58463143647772, + "AZ", 2.94392085027928, + "WV", 2.76758759555943, + "WI", 2.36071566781695, + "NV", 2.86215340333372, + "KY", 2.61504264826907, + "OH", 2.78246831834212, + "GA", 2.97349199669716, + "FL", 2.65882344312135, + "TX", 3.05585577141808, + "MO", 2.88335863923513, + "VA", 2.75911495377338, + "MD", 3.50647942709917, + "IN", 2.60169464796528, + "DE", 3.08754244164786, + "IL", 3.24309128613802, + "AR", 2.0524762800529, + "DC", 5.52868807141901, + "UT", 1.59734109505574, + "NJ", 3.79545402692342, + "SD", 3.48468101556672, + "PA", 3.37232607765983, + "NY", 3.94176183682454, + "NH", 1.92554694447792, + "WA", 2.21449552773719, + "TN", 2.79786645895306, + "WY", 1.1964441679329, + "SC", 2.43140559371769, + "MA", 4.00477289682913, + "ME", 2.28629239107603, + "CT", 3.95276120957787, + "AL", 2.75515844798994, + "KS", 2.1345078773505, + "NE", 1.91159958628961, + "CA", 2.85723812270986, + "AK", 1.08620385330817, + "LA", 3.33473479377281, + "MT", 1.50269335685785, + "NC", 2.72948112563802, + "MN", 2.69422400091221, + "OR", 2.32741128625208, + "RI", 3.53443674219184, + "MS", 2.44634020709629, + "HI", 2.84448243254587, + "ID", 1.42051075478839, + "CO", 2.18594457969623 + ) + +usethis::use_data(neph_per_100K_df, overwrite = TRUE) + +## 3. Grid Data Frame for asn_tilegrid() + +# fmt: skip + +grid_df <- + tibble::tribble( + ~State, ~x, ~y, + "AL", 7, 7, + "AK", 1, 1, + "AZ", 2, 6, + "AR", 5, 6, + "CA", 1, 5, + "CO", 3, 5, + "CT", 10, 4, + "DC", 9, 6, + "DE", 10, 5, + "FL", 9, 8, + "GA", 8, 7, + "HI", 1, 8, + "ID", 2, 3, + "IL", 6, 3, + "IN", 6, 4, + "IA", 5, 4, + "KS", 4, 6, + "KY", 6, 5, + "LA", 5, 7, + "ME", 11, 1, + "MD", 9, 5, + "MA", 10, 3, + "MI", 7, 3, + "MN", 5, 3, + "MS", 6, 7, + "MO", 5, 5, + "MT", 3, 3, + "NE", 4, 5, + "NV", 2, 4, + "NH", 11, 2, + "NJ", 9, 4, + "NM", 3, 6, + "NY", 9, 3, + "NC", 7, 6, + "ND", 4, 3, + "OH", 7, 4, + "OK", 4, 7, + "OR", 1, 4, + "PA", 8, 4, + "RI", 11, 4, + "SC", 8, 6, + "SD", 4, 4, + "TN", 6, 6, + "TX", 4, 8, + "UT", 2, 5, + "VT", 10, 2, + "VA", 8, 5, + "WA", 1, 3, + "WV", 7, 5, + "WI", 6, 2, + "WY", 3, 4 + ) |> + dplyr::mutate( + y = dplyr::case_when( + y == 1 ~ 12, + y == 2 ~ 11, + y == 3 ~ 10, + y == 4 ~ 9, + y == 5 ~ 8, + y == 6 ~ 7, + y == 7 ~ 6, + y == 8 ~ 5, + y == 9 ~ 4, + y == 10 ~ 3, + y == 11 ~ 2, + y == 12 ~ 1 + ) + ) + +usethis::use_data(grid_df, overwrite = TRUE) diff --git a/data/board_prep_df.rda b/data/board_prep_df.rda new file mode 100644 index 0000000000000000000000000000000000000000..854d156fd37384e27b8e7243a6ffc04378f179d1 GIT binary patch literal 1187 zcmV;U1YG+|N+?ld|3Ez}-@w1`|KLCXKmY&%;0S*B z_y7&C0JTU;B`F{ynq*`$V1|q)2-8N4K+`5h00JD-BO#LnG+{7CnlxetnKCc{5ayW~ z445IK34%1yqYyO7k$?b#PgN=;GyrLc00E(qkPJWo0X0$)PeD)6m`z8d#54h*$a+Sa zJx8gN8fpb4P?IT{K-xe63`T%x003yv)sET-Xx_%=_V!xwR{p%6{S>ZT3cUD2Y__O) z@^HZZw76-qIck%e3USrP2F;Xl(KzYi(wwzia^a3xTz1hLTS>8PFBVmCqO5C0($Q+- zD!D6&wvAksxV2nWaT{Y>kd3Xyl*v~#lL;YhbTzsmv1_3*2-KDexUB|*5=6+g#xau7 zv}oG6+-kXjnMH)iiLNXrn1V=#Nujb4v@+tx*y7d1$c>F4kQOWoZF4}9K&cs|Mg}N^ zM8z6|V@77xxInI+aF7ESqZx+AV<{5Q6?8T%m`Q-l8f?lY6EJCzj8Ozy6GRjSq^Q{_ zOC`4zc-K)WOj#~H%(Mi0`+Ia>1z2@)s!M}@@AFDXy7yM|o&R^9w{mN3 zjM)exj9{rT48##3k{MXhqhzTI7#T_il!*#LNhpdEG%!j-C4!AfL`E5)$+INU*jEZ8 z7{Nf3L=zfyI(G8gLL_9^B1S~Yl(I$&B1$w!Vl0*dh}U7X8z>BnQLse&Za4J_kCDIc_D$P>7 z-ycZ4x+yNN@AS-GcuN&UzX>u4l}flp(@l{NIezIwnp8YEN#ak;(Uw|cRiUM5XjqvB zE0UzRkez?G-MJ#Pl&>%G)#W`OR~OsXFHg5Tc@Q3LP4d5g9aMMe{e1mYM>l0C?U!E; zuGKt(?sgCyQ5;f?uD>^{1b4i}N%AAK*4EiEqhw}E-|y3wVPaCV77N^5g5xd9Ymr<3 zG8J=XEz~O0q(ekiX{CuHl{+$_-Gp#0Q>c{X-RV@Wej#l_u1{9UR)|%v6)NEg*e-44 zRc+FxTX_6%mn|a5vlnll{OL+Kc>?MB1<~54OsH}Y#?po4g9>xy9VjUX&{E)T{5=NWK_{zrVAW1Xf(7&q%hG zq$_}a=!n{W BCcgjx literal 0 HcmV?d00001 diff --git a/data/grid_df.rda b/data/grid_df.rda new file mode 100644 index 0000000000000000000000000000000000000000..2f566d1070f531739c419ffa23a91a83c7d67d2c GIT binary patch literal 404 zcmV;F0c-w3T4*^jL0KkKSf2te=u-|)YuoZvtJ00KY(umMwK z*fLWDj3ZEJG8zET(VC3YQxFHJ^HL2{!33j22*5$336Nj{Xwj2R0|^wQ@@fqY4W!f1 zLqIaTG$>Iq0t!V%Bzi?$__CC+ghMbm zqA8lPf;4eGq*FJF;47$a2N3`PG=WRUzEg-IV{BhuES5e)+fI#0U~4u z7v<{LJssKU@X2YEW}R!N0^G3HI@_&V(?*D?k#}y~xf5mAAZ&>1_-6=%^MnNiee038o%u(APx%A4FUvN==?c{Z05W&7oO y>C}jW*Gypw70MI>683RK=8UWDIkjT(7dVmc80MHnN zKxkrU05k?njRENZ5mN#to~CIH0000D0002c0000000000XaLXv0000005nAe&?X6* zXiYGfOqeE2jTo9>nlMcmBPJ#$)MUhD!Wl6#112T`FqlRF6HJ-_GHHrUAT+bF5dd5S zG9^)hUVQWh1gdE4f9h5ML{sNMn?cG@L_`2kfb|y&Dik6`L=OoU6Aon3L~K+!uoPJH zL!5moKwisE{K}y2cV@R4_;h1Vl#bpTtoDq;44|5XCA<1ZN1~t(|P0 z>*C58_5K?+o`i3saF>hidVyiU(HjTigD4+y{FXs)HM-&=^X&`=;0s=Xx)9~x#;VNI zb#^~Y%&P}5_o~O2#Kpr#$db|AW3p=(x~Z`=iq*AJpZLa}`Dc+WYU-j4OFb&Xdr5TG z;)3|^YlLTKnG$Jfs3R~N*pEo)JUG7B;UZGVaPy4X!3yI0K71!3&l7v=+Ty!ib*Ji3^YkZ zXtIb&gSn~7u>=IrfCta8nJm|;Z{O#F!UyV*BdPTa?*BVNN5cWxjovyMPjD0uwt(xb zIsj+_1OO&lopa%K-5fgxhkobI9X>S+n8PoJre*8+WXiZMGS`^G`DDtX5)meq|H`_$T-3mla_wj0TiO_hD_j3HGyz(1L z$KvB`y&`Veu)==IT^LqUX8e;6HNak?8GdIB^;i+jW3E+lL4Q^nBS-^8aj`BZc1*kn TFl`tD|BJaIoG3^W$=+Ll!MTXo literal 0 HcmV?d00001 diff --git a/man/asn_tilegrid.Rd b/man/asn_tilegrid.Rd new file mode 100644 index 0000000..c3e8697 --- /dev/null +++ b/man/asn_tilegrid.Rd @@ -0,0 +1,61 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/asn_tilegrid.R +\name{asn_tilegrid} +\alias{asn_tilegrid} +\title{Create a U.S. Tilegrid Choropleth Map in ggplot2 in style of The Economist} +\usage{ +asn_tilegrid( + data = df, + data_source = "Source", + plot_title = "Plot Title", + state_column = "state_column_name", + numeric_column = n, + plot_panel_color = "#ffffff", + palette = c("#FCC8B4", "#FAAA90", "#F58469", "#EF1B26"), + breaks = c(1, 2, 6, 11), + zero_color = NULL, + na_color = NULL +) +} +\arguments{ +\item{data}{A data frame, comprising a column with 2-letter USPS state abbreviations and a column with a +numeric variable to be visualized in a tilegrid choropleth map.} + +\item{data_source}{Source of the numeric data visualized in the choropleth.} + +\item{plot_title}{Plot title.} + +\item{state_column}{Column containing 2-letter USPS state abbreviations.} + +\item{numeric_column}{Column containing numeric data being visualized in choropleth.} + +\item{plot_panel_color}{Background color for plot.} + +\item{palette}{Vector of hex colors mapping numeric column to choropleth map fill color.} + +\item{breaks}{Numeric vector of breaks corresponding to colors in the color palette mapping to the numeric column.} + +\item{zero_color}{Optional hex color to indicate states with a 0 numeric value.} + +\item{na_color}{Optional hex color to indicate states with missing values.} +} +\value{ +ggplot2 object +} +\description{ +Create a U.S. Tilegrid Choropleth Map in ggplot2 in style of The Economist +} +\examples{ +asn_tilegrid( + data = neph_per_100K_df, + data_source = "AMA PPD and U.S. Census Bureau.", + plot_title = "Ratio of Nephrologists per 100K Adult Population", + state_column = "MailState", + numeric_column = neph_per_100k, + plot_panel_color = "#ffffff", + palette = c("#f0f8ff", "#a0bdd8", "#5081b2", "#00468b"), + breaks = c(2.21, 3.1, 4, 5.6), + zero_color = NULL, + na_color = "#EEECE6" +) +} diff --git a/man/board_prep_df.Rd b/man/board_prep_df.Rd new file mode 100644 index 0000000..97313cc --- /dev/null +++ b/man/board_prep_df.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{board_prep_df} +\alias{board_prep_df} +\title{Board Prep Resources} +\format{ +A data frame with 8 columns +\enumerate{ +\item \code{q6}: Repondent medical school location, either "United States" or "Other country". +\item \code{q65_1}: ASN Kidney Self-Assessment Program (KSAP) selected as a used resource (\if{html}{\out{}} = "No"). +\item \code{q65_2}: ASN Nephrology Self-Assessment Program (NephSAP) selected as a used resource (\if{html}{\out{}} = "No"). +\item \code{q65_3}: ASN Board Review Course & Update selected as a used resource (\if{html}{\out{}} = "No"). +\item \code{q65_4}: Oakstone/Brigham Intensive Review of Nephrology Course (\if{html}{\out{}} = "No"). +\item \code{q65_5}: Other board review course (\if{html}{\out{}} = "No"). +\item \code{q65_6}: Other resource(s) (please specify) (\if{html}{\out{}} = "No"). +\item \code{q65_6_text}: Free text response describing other resource(s) used. +} +} +\source{ +\url{https://data.asn-online.org/posts/2025_fellow_survey/} +} +\usage{ +board_prep_df +} +\description{ +Resources used by nephrology fellows in preparation for initial board certication in +nephrology. This is a synthesized data set generated based on proportions of actual responses to +measures in the 2025 ASN Nephrology Fellow Survey. +} +\examples{ +board_prep_df + +} +\keyword{datasets} diff --git a/man/check_all.Rd b/man/check_all.Rd index 9194ff2..d2dde43 100644 --- a/man/check_all.Rd +++ b/man/check_all.Rd @@ -35,38 +35,18 @@ A data frame. Count number of unique responses to 'Select All'/'Check All' survey questions } \examples{ - -# Toy Dataset -mouse_cheese_df <- - dplyr::tribble( - ~Q1, ~Q2_1, ~Q2_2, ~Q2_3, ~Q2_4, ~Q2_TEXT, - "Country", NA, NA, NA, "Colby", "Brie", - "City", NA, "Gruyere", NA, NA, "", - "City", NA, NA, "Swiss", NA, "Parmesan", - "City", NA, NA, NA, NA, "", - "Country", "Cheddar", NA, NA, "Colby", "", - "City", "Cheddar", NA, NA, "Colby", "", - "Country", "Cheddar", "Gruyere", NA, "Colby", "", - "City", NA, "Gruyere", NA, NA, "", - "City", NA, "Gruyere", NA, NA, "", - "City", NA, NA, "Swiss", NA, "Mozzarella", - "Country", "Cheddar", NA, NA, "Colby", "" - ) |> - dplyr::mutate( - dplyr::across(dplyr::everything(), as.factor) - ) # Grouped Results check_all( - data = mouse_cheese_df, - group_var = Q1, - column_prefix = "Q2", - free_text_var_suffix = "_TEXT" + data = board_prep_df, + group_var = q6, + column_prefix = "q65", + free_text_var_suffix = "_6_text" ) # Ungrouped Results check_all( - data = mouse_cheese_df, - column_prefix = "Q2", - free_text_var_suffix = "_TEXT" + data = board_prep_df, + column_prefix = "q65", + free_text_var_suffix = "_6_text" ) } diff --git a/man/grid_df.Rd b/man/grid_df.Rd new file mode 100644 index 0000000..c3e2dd6 --- /dev/null +++ b/man/grid_df.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{grid_df} +\alias{grid_df} +\title{Grid Data Frame for asn_tilegrid()} +\format{ +A data frame with 6 columns: +\enumerate{ +\item \code{State}: USPS codes for U.S. states and the District of Columbia. +\item \code{x}: Corresponding x coordinate for tilegrid. +\item \code{y}: Corresponding y coordinate for tilegrid. +} +} +\source{ +\url{https://github.com/kpivert/economist_choropleth} +} +\usage{ +grid_df +} +\description{ +Data frame of The Economist's 8 x 11 rectangular tile grid for the asn_tilegrid() function, adapted from the tilegrid +choropleth designed by The Economist Data Team. +} +\examples{ +grid_df + +} +\keyword{datasets} diff --git a/man/neph_per_100K_df.Rd b/man/neph_per_100K_df.Rd new file mode 100644 index 0000000..6100266 --- /dev/null +++ b/man/neph_per_100K_df.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{neph_per_100K_df} +\alias{neph_per_100K_df} +\title{Nephrologists per 100K U.S. Population by State} +\format{ +A data frame with 2 columns: +\enumerate{ +\item \code{MailState}: USPS codes for U.S. states and the District of Columbia. +\item \code{neph_per_100k}: Ratio of practicing nephrologists per 100K adult population in state/DC. +} +} +\source{ +\url{https://www.census.gov/data/datasets/time-series/demo/popest/2020s-counties-detail.html} +} +\usage{ +neph_per_100K_df +} +\description{ +Ratio of practicing nephrologists per 100K adult population per state and District of +Columbia in 2023. Nephrologist counts aggregated from the American Medical Assosciation +Physician Professional Database. U.S. adult population extracted from the U.S. Census Bureau. +} +\examples{ +neph_per_100K_df + +} +\keyword{datasets} From 1fd09b9ac6a1a5a507784e1c636c6fefe40abf9f Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:10:32 -0500 Subject: [PATCH 02/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 6437d22..0ab28f7 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -5,8 +5,8 @@ #' @import patchwork #' @import grid #' @param data A data frame, comprising a column with 2-letter USPS state abbreviations and a column with a -#' numeric variable to be visualized in a tilegrid choropleth map. -#' @param data_source Source of the numeric data visualized in the choropleth. +#' numeric variable to be visualized in a tilegrid choropleth map. +#' @param data_source Source of the numeric data visualized in the choropleth. #' @param plot_title Plot title. #' @param state_column Column containing 2-letter USPS state abbreviations. #' @param numeric_column Column containing numeric data being visualized in choropleth. From 745f83846ee6edda5c630c6a943df643a712b90c Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:10:55 -0500 Subject: [PATCH 03/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 0ab28f7..609af64 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -9,10 +9,10 @@ #' @param data_source Source of the numeric data visualized in the choropleth. #' @param plot_title Plot title. #' @param state_column Column containing 2-letter USPS state abbreviations. -#' @param numeric_column Column containing numeric data being visualized in choropleth. -#' @param plot_panel_color Background color for plot. -#' @param palette Vector of hex colors mapping numeric column to choropleth map fill color. -#' @param breaks Numeric vector of breaks corresponding to colors in the color palette mapping to the numeric column. +#' @param numeric_column Column containing numeric data being visualized in choropleth. +#' @param plot_panel_color Background color for plot. +#' @param palette Vector of hex colors mapping numeric column to choropleth map fill color. +#' @param breaks Numeric vector of breaks corresponding to colors in the color palette mapping to the numeric column. #' @param zero_color Optional hex color to indicate states with a 0 numeric value. #' @param na_color Optional hex color to indicate states with missing values. #' From 9609b8c14977e199fec88522b899757e3ab7a92b Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:11:08 -0500 Subject: [PATCH 04/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 609af64..9eef89e 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -27,8 +27,8 @@ #' state_column = "MailState", #' numeric_column = neph_per_100k, #' plot_panel_color = "#ffffff", -#' palette = c("#f0f8ff", "#a0bdd8", "#5081b2", "#00468b"), -#' breaks = c(2.21, 3.1, 4, 5.6), +#' palette = c("#f0f8ff", "#a0bdd8", "#5081b2", "#00468b"), +#' breaks = c(2.21, 3.1, 4, 5.6), #' zero_color = NULL, #' na_color = "#EEECE6" #' ) From c0bffaacdb617645c345564771752741e9ec17c5 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:11:19 -0500 Subject: [PATCH 05/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 9eef89e..00e9c79 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -32,7 +32,6 @@ #' zero_color = NULL, #' na_color = "#EEECE6" #' ) - asn_tilegrid <- function( data = df, data_source = "Source", From 5c75b431f3f5279e36208fff7e42361fcb9018cf Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:11:55 -0500 Subject: [PATCH 06/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index 747add4..a8525e5 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -37,7 +37,7 @@ check_all <- function( data, group_var = NULL, - column_prefix, + column_prefix, free_text_var_suffix = "_TEXT" ) { From b2f889864a1b4c11640c2913c6e26d80b24f19a2 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:12:11 -0500 Subject: [PATCH 07/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index a8525e5..8d8473e 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -40,7 +40,6 @@ check_all <- function( column_prefix, free_text_var_suffix = "_TEXT" ) { - group_var_expr <- rlang::enquo(group_var) free_text_column <- paste0(column_prefix, free_text_var_suffix) has_free_text <- free_text_column %in% names(data) From e804255e7c10051fb5008e13e2454b18d17770f7 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:14:57 -0500 Subject: [PATCH 08/41] Update R/data.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.R b/R/data.R index bcb8f50..7a0d398 100644 --- a/R/data.R +++ b/R/data.R @@ -1,4 +1,4 @@ -#' Board Prep Resources +#' Board Prep Resources #' #' Resources used by nephrology fellows in preparation for initial board certication in #' nephrology. This is a synthesized data set generated based on proportions of actual responses to From 788cf0ffa1ae9fb390c53288d1f9f9f7c9bcc339 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:15:23 -0500 Subject: [PATCH 09/41] Update R/data.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.R b/R/data.R index 7a0d398..e1c97ef 100644 --- a/R/data.R +++ b/R/data.R @@ -22,7 +22,7 @@ "board_prep_df" #' Nephrologists per 100K U.S. Population by State -#' +#' #' Ratio of practicing nephrologists per 100K adult population per state and District of #' Columbia in 2023. Nephrologist counts aggregated from the American Medical Assosciation #' Physician Professional Database. U.S. adult population extracted from the U.S. Census Bureau. From 3740d68544568a9fb7d6d1ee6b138d8e06f9d9d6 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:15:46 -0500 Subject: [PATCH 10/41] Update R/data.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/data.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/data.R b/R/data.R index e1c97ef..f298689 100644 --- a/R/data.R +++ b/R/data.R @@ -1,8 +1,8 @@ #' Board Prep Resources #' -#' Resources used by nephrology fellows in preparation for initial board certication in -#' nephrology. This is a synthesized data set generated based on proportions of actual responses to -#' measures in the 2025 ASN Nephrology Fellow Survey. +#' Resources used by nephrology fellows in preparation for initial board certication in +#' nephrology. This is a synthesized data set generated based on proportions of actual responses to +#' measures in the 2025 ASN Nephrology Fellow Survey. #' #' @format A data frame with 8 columns #' 1. `q6`: Repondent medical school location, either "United States" or "Other country". From 74194648e9ded968f66c73b97f20cec9973dd334 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:16:02 -0500 Subject: [PATCH 11/41] Update R/data.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.R b/R/data.R index f298689..1059e3d 100644 --- a/R/data.R +++ b/R/data.R @@ -25,7 +25,7 @@ #' #' Ratio of practicing nephrologists per 100K adult population per state and District of #' Columbia in 2023. Nephrologist counts aggregated from the American Medical Assosciation -#' Physician Professional Database. U.S. adult population extracted from the U.S. Census Bureau. +#' Physician Professional Database. U.S. adult population extracted from the U.S. Census Bureau. #' #' @format A data frame with 2 columns: #' 1. `MailState`: USPS codes for U.S. states and the District of Columbia. From d872e8af87332ee4b2ce814cc37bb329c6c4d269 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:16:20 -0500 Subject: [PATCH 12/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 00e9c79..56979e3 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -43,8 +43,7 @@ asn_tilegrid <- function( breaks = c(1, 2, 6, 11), # Ascending Order zero_color = NULL, na_color = NULL - ) { - +) { ## 01 Ensure Palette Length and Breaks Are Same Length ---- pal <- palette From 98e67f83306260dd2e8daf6a036bcde1ad1f0eaa Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:16:46 -0500 Subject: [PATCH 13/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 56979e3..2549c58 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -74,7 +74,7 @@ asn_tilegrid <- function( dplyr::mutate( fill_color = dplyr::case_when( is.na({{ numeric_column }}) ~ na_color, - dplyr::between({{ numeric_column }}, 0, breaks[1]) ~ pal[1], + dplyr::between({{ numeric_column }}, 0, breaks[1]) ~ pal[1], dplyr::between({{ numeric_column }}, breaks[1], breaks[2]) ~ pal[2], dplyr::between({{ numeric_column }}, breaks[2], breaks[3]) ~ pal[3], dplyr::between({{ numeric_column }}, breaks[3], breaks[4]) ~ pal[4] From a7cff0bedb1177632bf01033b06d9cbcaca7a1b4 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:17:00 -0500 Subject: [PATCH 14/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 2549c58..e701b13 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -550,6 +550,5 @@ asn_tilegrid <- function( fill = plot_panel_color, color = plot_panel_color ) - ) - } + } } From 21c395c8cfa27968b499162a33845aa2c6255b32 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:17:17 -0500 Subject: [PATCH 15/41] Update data-raw/DATASET.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- data-raw/DATASET.R | 104 ++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R index 3f63e3f..f713b71 100644 --- a/data-raw/DATASET.R +++ b/data-raw/DATASET.R @@ -70,58 +70,58 @@ usethis::use_data(board_prep_df, overwrite = TRUE) neph_per_100K_df <- tibble::tribble( - ~MailState, ~neph_per_100k, - "ND", 2.66143841875072, - "VT", 2.6205935490236, - "OK", 2.04238213609549, - "MI", 2.81652259426326, - "NM", 2.6400598916444, - "IA", 1.58463143647772, - "AZ", 2.94392085027928, - "WV", 2.76758759555943, - "WI", 2.36071566781695, - "NV", 2.86215340333372, - "KY", 2.61504264826907, - "OH", 2.78246831834212, - "GA", 2.97349199669716, - "FL", 2.65882344312135, - "TX", 3.05585577141808, - "MO", 2.88335863923513, - "VA", 2.75911495377338, - "MD", 3.50647942709917, - "IN", 2.60169464796528, - "DE", 3.08754244164786, - "IL", 3.24309128613802, - "AR", 2.0524762800529, - "DC", 5.52868807141901, - "UT", 1.59734109505574, - "NJ", 3.79545402692342, - "SD", 3.48468101556672, - "PA", 3.37232607765983, - "NY", 3.94176183682454, - "NH", 1.92554694447792, - "WA", 2.21449552773719, - "TN", 2.79786645895306, - "WY", 1.1964441679329, - "SC", 2.43140559371769, - "MA", 4.00477289682913, - "ME", 2.28629239107603, - "CT", 3.95276120957787, - "AL", 2.75515844798994, - "KS", 2.1345078773505, - "NE", 1.91159958628961, - "CA", 2.85723812270986, - "AK", 1.08620385330817, - "LA", 3.33473479377281, - "MT", 1.50269335685785, - "NC", 2.72948112563802, - "MN", 2.69422400091221, - "OR", 2.32741128625208, - "RI", 3.53443674219184, - "MS", 2.44634020709629, - "HI", 2.84448243254587, - "ID", 1.42051075478839, - "CO", 2.18594457969623 + ~MailState , ~neph_per_100k , + "ND" , 2.66143841875072 , + "VT" , 2.6205935490236 , + "OK" , 2.04238213609549 , + "MI" , 2.81652259426326 , + "NM" , 2.6400598916444 , + "IA" , 1.58463143647772 , + "AZ" , 2.94392085027928 , + "WV" , 2.76758759555943 , + "WI" , 2.36071566781695 , + "NV" , 2.86215340333372 , + "KY" , 2.61504264826907 , + "OH" , 2.78246831834212 , + "GA" , 2.97349199669716 , + "FL" , 2.65882344312135 , + "TX" , 3.05585577141808 , + "MO" , 2.88335863923513 , + "VA" , 2.75911495377338 , + "MD" , 3.50647942709917 , + "IN" , 2.60169464796528 , + "DE" , 3.08754244164786 , + "IL" , 3.24309128613802 , + "AR" , 2.0524762800529 , + "DC" , 5.52868807141901 , + "UT" , 1.59734109505574 , + "NJ" , 3.79545402692342 , + "SD" , 3.48468101556672 , + "PA" , 3.37232607765983 , + "NY" , 3.94176183682454 , + "NH" , 1.92554694447792 , + "WA" , 2.21449552773719 , + "TN" , 2.79786645895306 , + "WY" , 1.1964441679329 , + "SC" , 2.43140559371769 , + "MA" , 4.00477289682913 , + "ME" , 2.28629239107603 , + "CT" , 3.95276120957787 , + "AL" , 2.75515844798994 , + "KS" , 2.1345078773505 , + "NE" , 1.91159958628961 , + "CA" , 2.85723812270986 , + "AK" , 1.08620385330817 , + "LA" , 3.33473479377281 , + "MT" , 1.50269335685785 , + "NC" , 2.72948112563802 , + "MN" , 2.69422400091221 , + "OR" , 2.32741128625208 , + "RI" , 3.53443674219184 , + "MS" , 2.44634020709629 , + "HI" , 2.84448243254587 , + "ID" , 1.42051075478839 , + "CO" , 2.18594457969623 ) usethis::use_data(neph_per_100K_df, overwrite = TRUE) From df2d6a968eacf2dd0e598afd7e7607aaf68029c9 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:17:29 -0500 Subject: [PATCH 16/41] Update R/data.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.R b/R/data.R index 1059e3d..5add52d 100644 --- a/R/data.R +++ b/R/data.R @@ -31,7 +31,7 @@ #' 1. `MailState`: USPS codes for U.S. states and the District of Columbia. #' 2. `neph_per_100k`: Ratio of practicing nephrologists per 100K adult population in state/DC. #' @source -#' +#' #' @examples #' neph_per_100K_df #' From c21a41736327622b65f517347a31f0b0b1ee421c Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:17:59 -0500 Subject: [PATCH 17/41] Update R/data.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.R b/R/data.R index 5add52d..1d21ad5 100644 --- a/R/data.R +++ b/R/data.R @@ -40,7 +40,7 @@ #' Grid Data Frame for asn_tilegrid() #' #' Data frame of The Economist's 8 x 11 rectangular tile grid for the asn_tilegrid() function, adapted from the tilegrid -#' choropleth designed by The Economist Data Team. +#' choropleth designed by The Economist Data Team. #' #' @format A data frame with 6 columns: #' 1. `State`: USPS codes for U.S. states and the District of Columbia. From e7770a21bd263ad0243b3e9dced943c5cc51f2be Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:18:12 -0500 Subject: [PATCH 18/41] Update R/data.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.R b/R/data.R index 1d21ad5..c629633 100644 --- a/R/data.R +++ b/R/data.R @@ -50,4 +50,4 @@ #' @examples #' grid_df #' -"grid_df" \ No newline at end of file +"grid_df" From dc4f558bcdf609e262fff1924d2dbc21a3b15c84 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:18:22 -0500 Subject: [PATCH 19/41] Update data-raw/DATASET.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- data-raw/DATASET.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R index f713b71..52bc3b8 100644 --- a/data-raw/DATASET.R +++ b/data-raw/DATASET.R @@ -2,7 +2,7 @@ set.seed(20260116) -board_prep_df <- +board_prep_df <- data.frame( q6 = sample( c("United States", "Other country"), From 31276cf0a3e25459d4d7993023cbf02ba414e0ea Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:18:38 -0500 Subject: [PATCH 20/41] Update data-raw/DATASET.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- data-raw/DATASET.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R index 52bc3b8..2664c25 100644 --- a/data-raw/DATASET.R +++ b/data-raw/DATASET.R @@ -29,7 +29,10 @@ board_prep_df <- replace = TRUE ), q65_4 = sample( - c("Oakstone/Brigham Intensive Review of Nephrology Course", NA_character_), + c( + "Oakstone/Brigham Intensive Review of Nephrology Course", + NA_character_ + ), size = 400, prob = c(0.0442, 1 - 0.0442), replace = TRUE From e3ab713955971e0ed000185c3c8b0d973c2af799 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:18:52 -0500 Subject: [PATCH 21/41] Update data-raw/DATASET.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- data-raw/DATASET.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R index 2664c25..d4b8fb9 100644 --- a/data-raw/DATASET.R +++ b/data-raw/DATASET.R @@ -65,7 +65,7 @@ board_prep_df <- rep(NA_character_, 10), "Comprehensive" ) - ) + ) usethis::use_data(board_prep_df, overwrite = TRUE) From fc1a88766ecf925fef64000fbe7b558e4edd5cf9 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:19:09 -0500 Subject: [PATCH 22/41] Update data-raw/DATASET.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- data-raw/DATASET.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R index d4b8fb9..be600f0 100644 --- a/data-raw/DATASET.R +++ b/data-raw/DATASET.R @@ -71,7 +71,7 @@ usethis::use_data(board_prep_df, overwrite = TRUE) ## 2. Ratio of Nephrologists per 100K U.S. Population by State -neph_per_100K_df <- +neph_per_100K_df <- tibble::tribble( ~MailState , ~neph_per_100k , "ND" , 2.66143841875072 , From 750af72ed5be99a9550ba331c415f3deaf295c68 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:19:23 -0500 Subject: [PATCH 23/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index 8d8473e..2f85135 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -43,7 +43,6 @@ check_all <- function( group_var_expr <- rlang::enquo(group_var) free_text_column <- paste0(column_prefix, free_text_var_suffix) has_free_text <- free_text_column %in% names(data) - # Select relevant columns if (rlang::quo_is_null(group_var_expr)) { if (has_free_text) { From c85a1ef171f4eefd6ec4483ebe5677d032e5d766 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:19:34 -0500 Subject: [PATCH 24/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index 2f85135..1567fc7 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -46,7 +46,7 @@ check_all <- function( # Select relevant columns if (rlang::quo_is_null(group_var_expr)) { if (has_free_text) { - data_filtered <- + data_filtered <- data |> dplyr::select(tidyselect::contains(column_prefix)) |> dplyr::select(!tidyselect::all_of(free_text_column)) From d439a5e75436504c640b497451ec4ab6a208f39f Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:19:48 -0500 Subject: [PATCH 25/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index 1567fc7..bc0c776 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -51,7 +51,7 @@ check_all <- function( dplyr::select(tidyselect::contains(column_prefix)) |> dplyr::select(!tidyselect::all_of(free_text_column)) } else { - data_filtered <- + data_filtered <- data |> dplyr::select(tidyselect::contains(column_prefix)) } From 9c1bd374ebd599ad385e8bb4542925333f665a4b Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:19:58 -0500 Subject: [PATCH 26/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index bc0c776..447139e 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -57,7 +57,7 @@ check_all <- function( } } else { if (has_free_text) { - data_filtered <- + data_filtered <- data |> dplyr::select(!!group_var_expr, tidyselect::contains(column_prefix)) |> dplyr::select(!tidyselect::all_of(free_text_column)) From daf6e2ad520fc4772072f1543969e8993a978ac2 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:20:09 -0500 Subject: [PATCH 27/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index 447139e..81e4b5a 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -62,7 +62,7 @@ check_all <- function( dplyr::select(!!group_var_expr, tidyselect::contains(column_prefix)) |> dplyr::select(!tidyselect::all_of(free_text_column)) } else { - data_filtered <- + data_filtered <- data |> dplyr::select(!!group_var_expr, tidyselect::contains(column_prefix)) } From 0bc9c282535cb81070e121a244a967e194801a3f Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:20:20 -0500 Subject: [PATCH 28/41] Update R/check_all.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/check_all.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/check_all.R b/R/check_all.R index 81e4b5a..28dd665 100644 --- a/R/check_all.R +++ b/R/check_all.R @@ -67,7 +67,6 @@ check_all <- function( dplyr::select(!!group_var_expr, tidyselect::contains(column_prefix)) } } - # Pivot and count if (rlang::quo_is_null(group_var_expr)) { data_filtered |> From d84553c0e7605ad132cdb2ad1f92bd9eca58e177 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:20:42 -0500 Subject: [PATCH 29/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index e701b13..e84695e 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -63,8 +63,8 @@ asn_tilegrid <- function( ## 02 Build Tile Grid Choropleth ---- ## 02.01 If NA ---- - - if(is.null(zero_color) & !is.null(na_color)) { + + if (is.null(zero_color) & !is.null(na_color)) { choropleth <- grid_df |> dplyr::left_join( From 22ab3d461a4a6599283e4cdcac2a90078727b194 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:20:55 -0500 Subject: [PATCH 30/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index e84695e..8ab4907 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -131,11 +131,9 @@ asn_tilegrid <- function( color = plot_panel_color ) ) - - } else if(!is.null(zero_color) & is.null(na_color)) { - - ## 02.02 If Zero ---- - + } else if (!is.null(zero_color) & is.null(na_color)) { + ## 02.02 If Zero ---- + choropleth <- grid_df |> dplyr::left_join( From e86b29e7633b0319ef8daf98a077b62466f52efe Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:21:08 -0500 Subject: [PATCH 31/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 8ab4907..be9320e 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -143,7 +143,7 @@ asn_tilegrid <- function( dplyr::mutate( fill_color = dplyr::case_when( {{ numeric_column }} == 0 ~ zero_color, - dplyr::between({{ numeric_column }}, 0.01, breaks[1]) ~ pal[1], + dplyr::between({{ numeric_column }}, 0.01, breaks[1]) ~ pal[1], dplyr::between({{ numeric_column }}, breaks[1], breaks[2]) ~ pal[2], dplyr::between({{ numeric_column }}, breaks[2], breaks[3]) ~ pal[3], dplyr::between({{ numeric_column }}, breaks[3], breaks[4]) ~ pal[4] From b624195d01cf99af09f23536b18e0dbeb983c088 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:21:19 -0500 Subject: [PATCH 32/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index be9320e..2fdf4e1 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -200,12 +200,9 @@ asn_tilegrid <- function( color = plot_panel_color ) ) - - - } else if(is.null(na_color) & is.null(zero_color)){ - - ## 02.03 If Neither NA nor Zero - + } else if (is.null(na_color) & is.null(zero_color)) { + ## 02.03 If Neither NA nor Zero + choropleth <- grid_df |> dplyr::left_join( From c011d0c8f0a32033fa1afe00bb43343647cb640e Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:21:30 -0500 Subject: [PATCH 33/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 2fdf4e1..8dcc38c 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -211,7 +211,7 @@ asn_tilegrid <- function( ) |> dplyr::mutate( fill_color = dplyr::case_when( - dplyr::between({{ numeric_column }}, 0, breaks[1]) ~ pal[1], + dplyr::between({{ numeric_column }}, 0, breaks[1]) ~ pal[1], dplyr::between({{ numeric_column }}, breaks[1], breaks[2]) ~ pal[2], dplyr::between({{ numeric_column }}, breaks[2], breaks[3]) ~ pal[3], dplyr::between({{ numeric_column }}, breaks[3], breaks[4]) ~ pal[4] From eb8caa5077402ae2c050565fac730be77bed1a1e Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:21:45 -0500 Subject: [PATCH 34/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 8dcc38c..5f67335 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -324,8 +324,7 @@ asn_tilegrid <- function( ## 04 Determine if Zero or NA Color Guide Needed - if(is.null(zero_color) & !is.null(na_color)) { - + if (is.null(zero_color) & !is.null(na_color)) { zero_na_df <- data.frame( x = 1, From c9cae75698d892d3fee5bdc2e16f8b2ccd302647 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:22:01 -0500 Subject: [PATCH 35/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 5f67335..6f6605e 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -370,9 +370,7 @@ asn_tilegrid <- function( ) ) + ggplot2::coord_fixed(ratio = 1) - - } else if(!is.null(zero_color) & is.null(na_color)) { - + } else if (!is.null(zero_color) & is.null(na_color)) { zero_na_df <- data.frame( x = 1, From f97fb8ec2681069201663b8400630415908a3765 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:22:24 -0500 Subject: [PATCH 36/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 6f6605e..4df9541 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -416,7 +416,7 @@ asn_tilegrid <- function( ) ) + ggplot2::coord_fixed(ratio = 1) - } + } zero_na_df <- data.frame( From 65f9e6af1ca640cd37a52c4f25c6af89dcd849f9 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:22:43 -0500 Subject: [PATCH 37/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 4df9541..b4b3f65 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -466,7 +466,7 @@ asn_tilegrid <- function( ## 04 Assemble Plot ---- - ## 04.01 No Zero Color or NA Color + ## 04.01 No Zero Color or NA Color if (is.null(zero_color) & is.null(na_color)) { ( From 11fdf466fa87e893b766c8fd4ffa60001f072205 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:23:03 -0500 Subject: [PATCH 38/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index b4b3f65..2726355 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -469,14 +469,9 @@ asn_tilegrid <- function( ## 04.01 No Zero Color or NA Color if (is.null(zero_color) & is.null(na_color)) { - ( - ( - patchwork::plot_spacer() + - ggplot2::theme( - plot.margin = grid::unit(c(0, 0, 0, 30), "pt") - ) + - top_legend + - patchwork::plot_spacer() + ((patchwork::plot_spacer() + + ggplot2::theme( + plot.margin = grid::unit(c(0, 0, 0, 30), "pt") ) + patchwork::plot_layout(widths = c(2, 5, 2), nrow = 1) ) / From b08ef19e237da294d48b32d37bfba2e398f4f0f2 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:23:23 -0500 Subject: [PATCH 39/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 2726355..957d8ff 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -473,29 +473,31 @@ asn_tilegrid <- function( ggplot2::theme( plot.margin = grid::unit(c(0, 0, 0, 30), "pt") ) + - patchwork::plot_layout(widths = c(2, 5, 2), nrow = 1) - ) / - choropleth + - patchwork::plot_layout( - heights = c(0.05, 1) - ) + - patchwork::plot_annotation( - title = plot_title - ) & - ggplot2::theme( - plot.title = ggtext::element_textbox_simple( - size = 11, - family = "Gotham", - hjust = 0.25, - margin = ggplot2::margin(0, 0, 5, 0, unit = "pt") - ), - plot.background = ggplot2::element_rect( - color = plot_panel_color, - fill = plot_panel_color - ), - panel.background = ggplot2::element_rect( - fill = plot_panel_color, - color = plot_panel_color + top_legend + + patchwork::plot_spacer()) + + patchwork::plot_layout(widths = c(2, 5, 2), nrow = 1)) / + choropleth + + patchwork::plot_layout( + heights = c(0.05, 1) + ) + + patchwork::plot_annotation( + title = plot_title + ) & + ggplot2::theme( + plot.title = ggtext::element_textbox_simple( + size = 11, + family = "Gotham", + hjust = 0.25, + margin = ggplot2::margin(0, 0, 5, 0, unit = "pt") + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) ) ) From c06e64da706588b3b3a23ee0a4de3c95424c78e3 Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:23:37 -0500 Subject: [PATCH 40/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index 957d8ff..f39d32b 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -499,8 +499,6 @@ asn_tilegrid <- function( color = plot_panel_color ) ) - ) - } else { ## 04.02 Add Zero or NA Color Legend From 1b505f8e35a5739c21d3287292c57ebdd1de764c Mon Sep 17 00:00:00 2001 From: ASN Data Analytics Date: Mon, 19 Jan 2026 11:23:59 -0500 Subject: [PATCH 41/41] Update R/asn_tilegrid.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- R/asn_tilegrid.R | 68 +++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/R/asn_tilegrid.R b/R/asn_tilegrid.R index f39d32b..d468e49 100644 --- a/R/asn_tilegrid.R +++ b/R/asn_tilegrid.R @@ -500,42 +500,38 @@ asn_tilegrid <- function( ) ) } else { - - ## 04.02 Add Zero or NA Color Legend - - ( - ( - patchwork::plot_spacer() + - zero_na_legend + - ggplot2::theme( - plot.margin = grid::unit(c(0, 0, 0, 30), "pt") - ) + - top_legend + - patchwork::plot_spacer() - ) + - patchwork::plot_layout(widths = c(0.3, 1, 5, 1.4), nrow = 1) - ) / - choropleth + - patchwork::plot_layout( - heights = c(0.05, 1) - ) + - patchwork::plot_annotation( - title = plot_title - ) & - ggplot2::theme( - plot.title = ggtext::element_textbox_simple( - size = 11, - family = "Gotham", - hjust = 0.25, - margin = ggplot2::margin(0, 0, 5, 0, unit = "pt") - ), - plot.background = ggplot2::element_rect( - color = plot_panel_color, - fill = plot_panel_color - ), - panel.background = ggplot2::element_rect( - fill = plot_panel_color, - color = plot_panel_color + ## 04.02 Add Zero or NA Color Legend + + ((patchwork::plot_spacer() + + zero_na_legend + + ggplot2::theme( + plot.margin = grid::unit(c(0, 0, 0, 30), "pt") + ) + + top_legend + + patchwork::plot_spacer()) + + patchwork::plot_layout(widths = c(0.3, 1, 5, 1.4), nrow = 1)) / + choropleth + + patchwork::plot_layout( + heights = c(0.05, 1) + ) + + patchwork::plot_annotation( + title = plot_title + ) & + ggplot2::theme( + plot.title = ggtext::element_textbox_simple( + size = 11, + family = "Gotham", + hjust = 0.25, + margin = ggplot2::margin(0, 0, 5, 0, unit = "pt") + ), + plot.background = ggplot2::element_rect( + color = plot_panel_color, + fill = plot_panel_color + ), + panel.background = ggplot2::element_rect( + fill = plot_panel_color, + color = plot_panel_color + ) ) } }