Chloropleth Maps: Medicare Physician & Other Practitioners Dataset

medicare data-analytics highcharter highcharts rstats r-bloggers

Create interactive chloropleth maps for more intuitive data visualizations.

Andrew Bruce https://andrewbruce.netlify.app
2022-05-15

Introduction

This is intended to be a step-by-step guide for data analysis of large, publicly available datasets. I’ll be working with a Medicare dataset named Medicare Physician & Other Practitioners - by Provider and Service that can be downloaded here. Note: You can currently get this dataset with data going all the way back to 2013 (21 GB), but, in the interest of filesize, I’m only going to be working with the most recent data, from 2019 (3 GB).

Packages

Dataset

The Medicare Physician & Other Practitioners by Provider and Service dataset provides information on use, payments, and submitted charges organized by National Provider Identifier (NPI), Healthcare Common Procedure Coding System (HCPCS) code, and place of service. This dataset is based on information gathered from CMS administrative claims data for Original Medicare Part B beneficiaries available from the CMS Chronic Conditions Data Warehouse.

Data Cleaning

Let’s take a look at our initial data frame:

mpfs_preview <- head(mpfs, 10)
paged_table(mpfs_preview)

Rename Columns

The column names are looking pretty long and unwieldy:

names(mpfs)
   [1] "Rndrng_NPI"                    "Rndrng_Prvdr_Last_Org_Name"    "Rndrng_Prvdr_First_Name"      
   [4] "Rndrng_Prvdr_MI"               "Rndrng_Prvdr_Crdntls"          "Rndrng_Prvdr_Gndr"            
   [7] "Rndrng_Prvdr_Ent_Cd"           "Rndrng_Prvdr_St1"              "Rndrng_Prvdr_St2"             
  [10] "Rndrng_Prvdr_City"             "Rndrng_Prvdr_State_Abrvtn"     "Rndrng_Prvdr_State_FIPS"      
  [13] "Rndrng_Prvdr_Zip5"             "Rndrng_Prvdr_RUCA"             "Rndrng_Prvdr_RUCA_Desc"       
  [16] "Rndrng_Prvdr_Cntry"            "Rndrng_Prvdr_Type"             "Rndrng_Prvdr_Mdcr_Prtcptg_Ind"
  [19] "HCPCS_Cd"                      "HCPCS_Desc"                    "HCPCS_Drug_Ind"               
  [22] "Place_Of_Srvc"                 "Tot_Benes"                     "Tot_Srvcs"                    
  [25] "Tot_Bene_Day_Srvcs"            "Avg_Sbmtd_Chrg"                "Avg_Mdcr_Alowd_Amt"           
  [28] "Avg_Mdcr_Pymt_Amt"             "Avg_Mdcr_Stdzd_Amt"

I’ll go ahead and rename them:

mpfs <- mpfs |> 
    rename(npi = Rndrng_NPI,
           last = Rndrng_Prvdr_Last_Org_Name,
           first = Rndrng_Prvdr_First_Name,
           mid = Rndrng_Prvdr_MI,
           cred = Rndrng_Prvdr_Crdntls,
           gender = Rndrng_Prvdr_Gndr,
           entity = Rndrng_Prvdr_Ent_Cd,
           street = Rndrng_Prvdr_St1,
           street2 = Rndrng_Prvdr_St2,
           city = Rndrng_Prvdr_City,
           state = Rndrng_Prvdr_State_Abrvtn,
           fips = Rndrng_Prvdr_State_FIPS,
           zip = Rndrng_Prvdr_Zip5,
           ruca = Rndrng_Prvdr_RUCA,
           ruca_desc = Rndrng_Prvdr_RUCA_Desc,
           country = Rndrng_Prvdr_Cntry,
           ptype = Rndrng_Prvdr_Type,
           par = Rndrng_Prvdr_Mdcr_Prtcptg_Ind,
           hcpcs = HCPCS_Cd,
           hcpcs_desc = HCPCS_Desc,
           hcpcs_drug = HCPCS_Drug_Ind,
           pos = Place_Of_Srvc,
           pts = Tot_Benes,
           proc = Tot_Srvcs,
           proc_day = Tot_Bene_Day_Srvcs,
           avg_sub = Avg_Sbmtd_Chrg,
           avg_allow = Avg_Mdcr_Alowd_Amt,
           avg_pymt = Avg_Mdcr_Pymt_Amt,
           avg_stand = Avg_Mdcr_Stdzd_Amt
           )

Subset Data Frame

To cut down on the file size for this example, I want to subset this data frame for two conditions - E&M Codes in the state of Georgia:

mpfs_ga_em <- mpfs |> 
  filter(state == "GA") |> 
  filter(str_detect(hcpcs, "^992"))

mpfs_ga_em_preview <- head(mpfs_ga_em, 10)
paged_table(mpfs_ga_em_preview)

Zipcode Dataset

I’d like to include some other information that isn’t included in this dataset, such as the county name. I came across a zip code dataset online that I’ll use:

zip_code_database_preview <- head(zip_code_database, 10)
paged_table(zip_code_database_preview)

I’ll subset it for Georgia:

ga_zip <- zip_code_database |>
  filter(state == "GA")

ga_zip_preview <- head(ga_zip, 10)
paged_table(ga_zip_preview)

Left-Join mpfs_ga_em & ga_zip Datasets

ga_zip$zip  <- as.character(ga_zip$zip)

ga_zip <- ga_zip |> 
  select(zip, county, latitude, longitude, irs_estimated_population)

combined_df <- left_join(mpfs_ga_em, ga_zip, by = "zip")

combined_df_preview <- head(combined_df, 10)
paged_table(combined_df_preview)

County FIPS Codes

## Get County FIPS codes from tidycensus package
data(fips_codes)

## Filter to "GA"
ga_fips_codes <- fips_codes |> 
  filter(state == "GA")

## Join "state" & "county" FIPS codes for complete county code
## Select only needed columns
ga_fips_codes <- ga_fips_codes |> 
  unite("fips_county_code", c("state_code", "county_code"), sep = "", remove = TRUE) |> 
  select(fips_county_code, county)

## Join the two data frames
combined_df <- left_join(combined_df, ga_fips_codes, by = "county")


## Remove Unneeded Columns
## Rename columns for clarity
combined_df_map <- combined_df |> 
  select(-npi, -mid, -gender, -cred, 
         -street2, -state, -country, 
         -hcpcs_drug, -proc_day, 
         -avg_stand, -fips) |> 
  rename(fips = fips_county_code,
         population = irs_estimated_population
         )

combined_df_map_preview <- head(combined_df_map, 10)
paged_table(combined_df_map_preview)

Remove “County” Text from county column

combined_df_map$county <- gsub(" County", "", as.character(combined_df_map$county))

combined_df_map_preview <- head(combined_df_map, 10)
paged_table(combined_df_map_preview)

Summarize by Zip Code and EM Code

combined_df_map <- combined_df_map |>
  group_by(
    zip, county, fips, city, ruca, hcpcs
  ) |> 
  summarise(
        pts                         = sum(pts),
        proc                        = round(sum(proc)),
        avg_sub                     = round(mean(avg_sub), 2),
        avg_allow                   = round(mean(avg_allow), 2),
        avg_pymt                    = round(mean(avg_pymt), 2), 
        .groups                     = 'drop')|>
    arrange(desc(proc))

combined_df_map_preview <- head(combined_df_map, 10)
paged_table(combined_df_map_preview)

Prepare Data for Plot

Subset by Individual EM Codes

New Patient E/M Codes

## 99202
map_99202 <- combined_df_map |> 
  filter(hcpcs == "99202") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## Statewide Average: $44.73
avg_99202 <- map_99202 |> 
  summarise(state_avg = mean(value))

map_99202_preview <- head(map_99202, 10)
paged_table(map_99202_preview)
## 99203
map_99203 <- combined_df_map |> 
  filter(hcpcs == "99203") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## State Average = 63.48
avg_99203 <- map_99203 |> 
  summarise(state_avg = mean(value))

map_99203_preview <- head(map_99203, 10)
paged_table(map_99203_preview)
## 99204
map_99204 <- combined_df_map |> 
  filter(hcpcs == "99204") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## State Average = 103.13
avg_99204 <- map_99204 |> 
  summarise(state_avg = mean(value))

map_99204_preview <- head(map_99204, 10)
paged_table(map_99204_preview)
## 99205
map_99205 <- combined_df_map |> 
  filter(hcpcs == "99205") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## State Average = 142.39
avg_99205 <- map_99205 |> 
  summarise(state_avg = mean(value))

map_99205_preview <- head(map_99205, 10)
paged_table(map_99205_preview)

Established Patient E/M Codes

## 99212
map_99212 <- combined_df_map |> 
  filter(hcpcs == "99212") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## State Average = 28.50
avg_99212 <- map_99212 |> 
  summarise(state_avg = mean(value))

map_99212_preview <- head(map_99212, 10)
paged_table(map_99212_preview)
## 99213
map_99213 <- combined_df_map |> 
  filter(hcpcs == "99213") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## State Average = 44.83
avg_99213 <- map_99213 |> 
  summarise(state_avg = mean(value))

map_99213_preview <- head(map_99213, 10)
paged_table(map_99213_preview)
## 99214
map_99214 <- combined_df_map |> 
  filter(hcpcs == "99214") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## State Average = 66.13
avg_99214 <- map_99214 |> 
  summarise(state_avg = mean(value))

map_99214_preview <- head(map_99214, 10)
paged_table(map_99214_preview)
## 99215
map_99215 <- combined_df_map |> 
  filter(hcpcs == "99215") |> 
  rename(value = avg_pymt) |> 
  select(county, city, zip, fips, ruca, pts, proc, value)

## State Average = 95.61
avg_99215 <- map_99215 |> 
  summarise(state_avg = mean(value))

map_99215_preview <- head(map_99215, 10)
paged_table(map_99215_preview)

Download Map Data from Highcharter package

Highcharter provides two functions for accessing and browsing different common maps:

download_map_data(): Download the geojson data from the highchartsJS collection. get_data_from_map(): Get the properties for each region in the map, as the keys from the map data.

# Download Georgia map data
map_layout_data <- download_map_data("countries/us/us-ga-all.js")

get_data_from_map(map_layout_data) |> 
  janitor::clean_names() |> 
  glimpse()
  Rows: 159
  Columns: 7
  $ hc_group    <chr> "admin2", "admin2", "admin2", "admin2", "admin2", "admin2", "admin2", "admin2"…
  $ hc_middle_x <dbl> 0.42, 0.38, 0.44, 0.54, 0.50, 0.34, 0.50, 0.50, 0.50, 0.45, 0.53, 0.57, 0.45, …
  $ hc_middle_y <dbl> 0.62, 0.50, 0.46, 0.41, 0.60, 0.37, 0.49, 0.48, 0.50, 0.41, 0.47, 0.55, 0.41, …
  $ hc_key      <chr> "us-ga-295", "us-ga-261", "us-ga-179", "us-ga-001", "us-ga-279", "us-ga-061", …
  $ hc_a2       <chr> "WA", "SU", "LI", "AP", "TO", "CL", "CA", "CO", "ME", "BL", "LA", "SC", "BU", …
  $ fips        <chr> "13295", "13261", "13179", "13001", "13279", "13061", "13037", "13077", "13199…
  $ name        <chr> "Walker", "Sumter", "Liberty", "Appling", "Toombs", "Clay", "Calhoun", "Coweta…

Creating the Chloropleth Maps

New Patient E/M Codes

Show code
## 99202
hc_99202 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99202,
    name = "99202",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99202 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$44.73</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99202 HCPCS Code Description:</b><br><em>New Patient Office or Other<br>Outpatient Visit (~10 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Data source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |>
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

## 99203
hc_99203 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99203,
    name = "99203",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99203 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$63.48</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99203 HCPCS Code Description:</b><br><em>New Patient Office or Other<br>Outpatient Visit (~15 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Data source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |>
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

## 99204
hc_99204 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99204,
    name = "99204",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99204 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$103.13</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99204 HCPCS Code Description:</b><br><em>New Patient Office or Other<br>Outpatient Visit (~25 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Data source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |>
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

## 99205
hc_99205 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99205,
    name = "99205",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99205 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$142.39</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99205 HCPCS Code Description:</b><br><em>New Patient Office or Other<br>Outpatient Visit (>30 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Data source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |>
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

crosstalk::bscols(
    widths = NA,
    hc_99202,
    hc_99203
)

Established Patient E/M Codes

Show code
## 99212
hc_99212 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99212,
    name = "99212",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99212 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$28.50</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99212 HCPCS Code Description:</b><br><em>Established Patient Office or<br>Other Outpatient Visit (~10 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Data source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |>
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

## 99213
hc_99213 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99213,
    name = "99213",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99213 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$44.83</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99213 HCPCS Code Description:</b><br><em>Established Patient Office or<br>Other Outpatient Visit (~15 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Data source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |>
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

## 99214
hc_99214 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99214,
    name = "99214",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99214 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$66.13</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99214 HCPCS Code Description:</b><br><em>Established Patient Office or<br>Other Outpatient Visit (~25 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |> 
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

## 99215
hc_99215 <- highchart(type = "map") |> 
  hc_add_series(
    data = map_99215,
    name = "99215",
    mapData = map_layout_data,
    joinBy = "fips",
    borderColor = "#FAFAFA",
    borderWidth = 0.15,
    nullColor = "#d3d3d3",
    tooltip = list(
    valueDecimals = 2,
    valuePrefix = "$",
    valueSuffix = " USD"),
    dataLabels = list(enabled = TRUE, format = "{point.county}")) |>
  hc_colorAxis(stops = color_stops(colors = viridisLite::viridis(5, direction = -1))) |> 
  hc_title(
    text = "99215 Average Medicare Payment: Georgia (2019)",
    align = "left", 
    style = list(fontSize = "18", color = "#000000", fontWeight = "bold")) |> 
  hc_subtitle(
    text = "Georgia Statewide Average: <b>$95.61</b>", 
    align = "left",
    style = list(fontSize = "16", color = "#000000", fontWeight = "normal")) |> 
  hc_legend(
    layout = "horizontal",
    reversed = TRUE,
    floating = TRUE,
    align = "right",
    verticalAlight = "top"
    ) |> 
  hc_caption(
    text = "<b>99215 HCPCS Code Description:</b><br><em>Established Patient Office or<br>Other Outpatient Visit (>30 min.)</em>"
  ) |> 
  hc_credits(
    enabled = TRUE,
    text = "Source: data.cms.gov",
    href = "https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners/medicare-physician-other-practitioners-by-provider-and-service"
  ) |> 
  hc_mapNavigation(enabled = TRUE,
    enableMouseWheelZoom = TRUE,
    enableDoubleClickZoom = TRUE) |> 
  hc_size(height = 900) |> 
  hc_chart(style = list(fontFamily = "Karla"))

crosstalk::bscols(
    widths = NA,
    hc_99212,
    hc_99213
)



Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/andrewallenbruce, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Bruce (2022, May 15). Andrew Bruce: Chloropleth Maps: Medicare Physician & Other Practitioners Dataset. Retrieved from https://andrewbruce.netlify.app/posts/chloropleth-maps-medicare-physician-other-practitioners/

BibTeX citation

@misc{bruce2022chloropleth,
  author = {Bruce, Andrew},
  title = {Andrew Bruce: Chloropleth Maps: Medicare Physician & Other Practitioners Dataset},
  url = {https://andrewbruce.netlify.app/posts/chloropleth-maps-medicare-physician-other-practitioners/},
  year = {2022}
}