CSC 495 Final Project

Braden Baker

Setup and Data

The first dataset is gathered from the ACS census data. It contains the coordinates of all the counties in Washington State. The other data sets are from Washington Geospatial Open Data Portal.

The first dataset from the geospatial data portal contains data about the demographics of disabled people over 65 years old in Washington State. https://geo.wa.gov/datasets/WADSHS::acs-2012-senior-estimates/data

The second dataset from the geospatial data portal contains data about the number of long term care nursing homes in Washington State. https://geo.wa.gov/datasets/WADSHS::long-term-care-nursing-homes/data

library(tidycensus)
library(tidyverse)
library(tigris)
library(leaflet)
library(htmltools)
library(gridExtra)
## Warning: package 'gridExtra' was built under R version 4.0.5
wa_counties <- counties(state = "WA")

American_Community_Survey_ACS_estimates_of_persons_with_disabilities_or_other_support_needs_ <- read_csv("American_Community_Survey_(ACS)_estimates_of_persons_with_disabilities_or_other_support_needs..csv")

Long_Term_Care_Nursing_Homes <- read_csv("Long_Term_Care_-_Nursing_Homes.csv")
glimpse(American_Community_Survey_ACS_estimates_of_persons_with_disabilities_or_other_support_needs_)
## Rows: 1,458
## Columns: 47
## $ FID                     <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,~
## $ Name                    <chr> "Census Tract 9501, Adams Co.", "Census Tract ~
## $ LEP_65pl                <dbl> 4, 6, 73, 26, 124, 0, 0, 12, 0, 9, 10, 30, 15,~
## $ LEP_65pl_MOE            <dbl> 31.14, 46.00, 71.05, 57.31, 88.03, 31.02, 44.0~
## $ LEP_65pl_Per            <dbl> 0.96, 2.62, 11.85, 8.78, 38.15, 0.00, 0.00, 2.~
## $ LEP_65pl_Per_MOE        <dbl> 7.50, 20.08, 11.35, 19.28, 26.06, 4.10, 3.77, ~
## $ Disab_65pl              <dbl> 172, 119, 256, 148, 129, 210, 460, 287, 203, 2~
## $ Disab_65pl_MOE          <dbl> 51.09, 45.69, 119.85, 57.38, 64.14, 67.01, 118~
## $ Disab_65pl_Per          <dbl> 46.87, 51.97, 42.52, 60.16, 39.69, 27.74, 39.5~
## $ Disab_65pl_Per_MOE      <dbl> 10.67, 16.86, 18.39, 18.13, 18.17, 8.20, 9.41,~
## $ HearDiff_65pl           <dbl> 77, 66, 159, 78, 35, 132, 299, 98, 85, 135, 80~
## $ HearDiff_65pl_MOE       <dbl> 32.30, 33.05, 89.26, 44.59, 40.60, 54.42, 85.0~
## $ HearDiff_65pl_Per       <dbl> 20.98, 28.82, 26.41, 31.71, 10.77, 17.44, 25.6~
## $ HearDiff_65pl_Per_MOE   <dbl> 8.00, 12.97, 13.95, 16.31, 12.20, 6.79, 6.57, ~
## $ VisionDiff_65pl         <dbl> 29, 12, 6, 35, 47, 25, 67, 34, 51, 46, 20, 17,~
## $ VisionDiff_65pl_MOE     <dbl> 27.37, 9.75, 31.43, 36.72, 42.00, 29.46, 44.65~
## $ VisionDiff_65pl_Per     <dbl> 7.90, 5.24, 1.00, 14.23, 14.46, 3.30, 5.76, 5.~
## $ VisionDiff_65pl_Per_MOE <dbl> 7.33, 4.10, 5.22, 14.50, 12.41, 3.87, 3.77, 4.~
## $ CognDiff_65pl           <dbl> 26, 29, 104, 12, 68, 41, 88, 35, 83, 104, 30, ~
## $ CognDiff_65pl_MOE       <dbl> 25.96, 20.93, 64.30, 24.00, 47.93, 30.81, 51.0~
## $ CognDiff_65pl_Per       <dbl> 7.08, 12.66, 17.28, 4.88, 20.92, 5.42, 7.56, 6~
## $ CognDiff_65pl_Per_MOE   <dbl> 6.97, 8.71, 10.16, 9.68, 13.80, 4.00, 4.28, 5.~
## $ MoveDiff_65pl           <dbl> 114, 82, 112, 102, 101, 131, 245, 228, 119, 16~
## $ MoveDiff_65pl_MOE       <dbl> 42.53, 37.15, 54.50, 47.73, 52.26, 59.25, 79.0~
## $ MoveDiff_65pl_Per       <dbl> 31.06, 35.81, 18.60, 41.46, 31.08, 17.31, 21.0~
## $ MoveDiff_65pl_Per_MOE   <dbl> 10.25, 14.19, 8.34, 16.43, 14.10, 7.47, 6.27, ~
## $ CareDiff_65pl           <dbl> 29, 10, 67, 41, 15, 38, 69, 58, 68, 94, 52, 96~
## $ CareDiff_65pl_MOE       <dbl> 26.32, 19.03, 68.03, 30.74, 27.50, 30.36, 41.6~
## $ CareDiff_65pl_Per       <dbl> 7.90, 4.37, 11.13, 16.67, 4.62, 5.02, 5.93, 10~
## $ CareDiff_65pl_Per_MOE   <dbl> 7.04, 8.25, 11.10, 11.79, 8.38, 3.95, 3.50, 6.~
## $ ILDiff_65pl             <dbl> 77, 41, 81, 53, 73, 65, 122, 64, 103, 158, 98,~
## $ ILDiff_65pl_MOE         <dbl> 36.78, 20.07, 60.96, 36.89, 47.20, 36.85, 56.1~
## $ ILDiff_65pl_Per         <dbl> 20.98, 17.90, 13.46, 21.54, 22.46, 8.59, 10.48~
## $ ILDiff_65pl_Per_MOE     <dbl> 9.33, 7.84, 9.80, 14.00, 13.40, 4.73, 4.65, 6.~
## $ Disab_2pl_65pl          <dbl> 83, 81, 150, 88, 91, 92, 228, 148, 128, 188, 9~
## $ Disab_2pl_65pl_MOE      <dbl> 39, 42, 98, 43, 55, 41, 79, 53, 57, 72, 51, 56~
## $ Disab_2pl_65pl_Per      <dbl> 22.62, 35.37, 24.92, 35.77, 28.00, 12.15, 19.5~
## $ Disab_2pl_65pl_Per_MOE  <dbl> 9.71, 16.84, 15.65, 15.15, 16.03, 5.22, 6.52, ~
## $ Pov_Disab_65pl          <dbl> 30, 25, 65, 3, 33, 18, 44, 30, 11, 36, 0, 2, 1~
## $ Pov_Disab_65pl_MOE      <dbl> 18, 27, 41, 6, 47, 20, 44, 36, 15, 30, 12, 5, ~
## $ Pov_Disab_65pl_Per      <dbl> 8.17, 10.92, 10.80, 1.22, 10.15, 2.38, 3.78, 5~
## $ Pov_Disab_65pl_Per_MOE  <dbl> 4.65, 11.58, 6.53, 2.42, 14.33, 2.63, 3.76, 6.~
## $ Pov_65pl                <dbl> 49, 50, 127, 30, 34, 63, 144, 59, 24, 55, 0, 1~
## $ Pov_65pl_MOE            <dbl> 22.80, 33.60, 63.89, 24.74, 47.10, 40.31, 82.6~
## $ Pov_65pl_Per            <dbl> 13.35, 21.83, 21.10, 12.20, 10.46, 8.32, 12.37~
## $ Pov_65pl_Per_MOE        <dbl> 5.67, 13.97, 9.92, 9.61, 14.35, 5.23, 7.00, 7.~
## $ GEOID                   <dbl> 53001950100, 53001950200, 53001950300, 5300195~
glimpse(Long_Term_Care_Nursing_Homes)
## Rows: 441
## Columns: 51
## $ X                       <dbl> -13620313, -13847307, -13847307, -13847307, -1~
## $ Y                       <dbl> 6051012, 6097879, 6097879, 6097879, 6033697, 6~
## $ OBJECTID                <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,~
## $ nf_location_num         <dbl> 1200, 31590, 31590, 31590, 1400, 31500, 400, 4~
## $ nf_loc_region_cde       <dbl> 2, 3, 3, 3, 2, 1, 0, 0, 2, 2, 1, 1, 2, 3, 1, 2~
## $ nf_loc_street_address   <chr> "4700 PHINNEY AVENUE NO", "530 BOGACHIEL WAY",~
## $ nf_loc_city             <chr> "SEATTLE", "FORKS", "FORKS", "FORKS", "SEATTLE~
## $ nf_loc_zip_cde          <dbl> 981031000, 98331, 98331, 98331, 981261000, 988~
## $ nf_loc_phone_num        <dbl> 2066327400, 3603746271, 3603746271, 3603746271~
## $ nf_loc_fax_num          <dbl> 2065450955, 3603741131, 3603741131, 3603741131~
## $ nf_mailing_address      <chr> "4700 PHINNEY AVE N", "530 BOGACHIEL WAY", "53~
## $ nf_mailing_city         <chr> "SEATTLE", "FORKS", "FORKS", "FORKS", "SEATTLE~
## $ nf_mailing_state        <chr> "WA", "WA", "WA", "WA", "WA", "WA", "WA", "WA"~
## $ nf_mailing_zip_cde      <dbl> 981031000, 98331, 98331, 98331, 981261000, 988~
## $ nf_Loc_Type             <chr> "NF", "NF", "NF", "NF", "NF", "NF", "IM", "IM"~
## $ nf_state_vendor_num     <dbl> 4104808, 4205407, 4205407, 4205407, 4107702, 4~
## $ nf_license_num          <dbl> 48, 54, 54, 54, 77, 107, 120, 120, 143, 274, 3~
## $ nf_fed_provider_num     <chr> "505470", "50A174", "50A174", "50A174", "50518~
## $ nf_name                 <chr> "COLUMBIA LUTHERAN HOME", "FORKS COMMUNITY HOS~
## $ nf_staff_last_name      <chr> "Heyer", NA, "Selman", "Cournyer", "BOYD", "MI~
## $ nf_staff_first_name     <chr> "David", NA, "David", "Timothy", "CHARLENE", "~
## $ nf_staff_mid_name       <chr> NA, NA, NA, NA, NA, "J", NA, NA, NA, NA, "R", ~
## $ NF_County_Name          <chr> "King", "Clallam", "Clallam", "Clallam", "King~
## $ nf_licensee_name        <chr> "COLUMBIA LUTHERAN MINISTRIES", "CLALLAM COUNT~
## $ nf_ownership_type_desc  <chr> "Non Profit Corporation", "Municipality", "Mun~
## $ nf_bed_type_cde         <chr> "BD89", "BD19", "BD19", "BD19", "BD89", "BD89"~
## $ nf_SSPS                 <dbl> 114121, 50737, 50737, 50737, 189255, 352908, N~
## $ RCSUnit                 <chr> "H", "C", "C", "C", "F", "A", "I", "I", "C", "~
## $ TOTAL_Beds_nf_bed_count <dbl> 116, 12, 12, 12, 215, 42, 270, 270, 160, 168, ~
## $ XVIII_Beds_nf_bed_count <dbl> 0, 0, 0, 0, 0, 0, NA, NA, 0, 0, 0, 0, 0, NA, 4~
## $ XIX_Beds_nf_bed_count   <dbl> 0, 12, 12, 12, 0, NA, NA, NA, 0, NA, NA, NA, 0~
## $ T1819_Beds_nf_bed_count <dbl> 116, 0, 0, 0, 215, 42, NA, NA, 160, 168, 117, ~
## $ Has_reports             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ Reports_Location        <chr> "https://fortress.wa.gov/dshs/adsaapps/lookup/~
## $ acAddressKey            <dbl> 7649066029, 2607780340, 2607780340, 2607780340~
## $ acAddressKeyUnit        <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ acAddress1              <chr> "4700 Phinney Ave N", "530 Bogachiel Way", "53~
## $ acAddress2              <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ acCity                  <chr> "Seattle", "Forks", "Forks", "Forks", "Seattle~
## $ acState                 <chr> "WA", "WA", "WA", "WA", "WA", "WA", "WA", "WA"~
## $ acZip                   <dbl> 98103, 98331, 98331, 98331, 98126, 98855, 9902~
## $ acPlus4                 <dbl> 6374, 9120, 9120, 9120, 2709, 8846, NA, NA, 74~
## $ gcWAMASId               <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ gcLocatorName           <chr> "PointAddress", "PointAddress", "PointAddress"~
## $ gcGrade                 <chr> "B", "B", "B", "B", "B", "C", "C", "C", "B", "~
## $ GDLPublishDate          <chr> "2020/03/10 01:59:41+00", "2020/03/10 01:59:41~
## $ GDLArchiveDate          <chr> NA, "2020/07/03 23:35:35+00", "2020/07/08 23:3~
## $ Latitude                <dbl> 47.66324, 47.94602, 47.94602, 47.94602, 47.558~
## $ Longitude               <dbl> -122.3534, -124.3925, -124.3925, -124.3925, -1~
## $ SCO_Latitude            <dbl> 47.66324, 47.94619, 47.94619, 47.94619, 47.558~
## $ SCO_Longitude           <dbl> -122.3539, -124.3932, -124.3932, -124.3932, -1~

Transforming Data

The number of long term care homes and number of beds in those home is extracted for each county. Then the number of disabled people over 65 and the number of those disabled over 65 that in are in poverty are extracted for each county. Both of these datasets are joined together with the Wacounties data set so they have the county geometry and a county label is generated for later.

## extract homes/beds per county
nursinghomes <- Long_Term_Care_Nursing_Homes %>%
  distinct(nf_location_num, .keep_all = TRUE) %>%
  group_by(NF_County_Name) %>%
  summarise(NumHomes = n(), NumBeds = sum(TOTAL_Beds_nf_bed_count))


head(nursinghomes)
## # A tibble: 6 x 3
##   NF_County_Name NumHomes NumBeds
##   <chr>             <int>   <dbl>
## 1 Adams                 1      39
## 2 Asotin                1      90
## 3 Benton                4     364
## 4 Chelan                3     220
## 5 Clallam               4     338
## 6 Clark                 9     819
## extract disabled over 65 pop per county
pop <- American_Community_Survey_ACS_estimates_of_persons_with_disabilities_or_other_support_needs_ %>%
  mutate(county = str_extract(Name, '\\b[^,]+$'),
         county = str_replace(county, " Co.", "")) %>%
  group_by(county) %>%
  summarise(numDis = sum(Disab_65pl), NumPov = sum(Pov_65pl), Num2Dis = sum(Disab_2pl_65pl))

head(pop)
## # A tibble: 6 x 4
##   county  numDis NumPov Num2Dis
##   <chr>    <dbl>  <dbl>   <dbl>
## 1 Adams      824    290     493
## 2 Asotin    1643    345     874
## 3 Benton    7067   1182    3917
## 4 Chelan    3752   1126    2096
## 5 Clallam   6342   1003    3241
## 6 Clark    18192   3934    9963
#join nursing home and disabled totals with county geometry
alldata <- left_join(wa_counties, nursinghomes, by = c("NAME" = "NF_County_Name"))
alldata <- left_join(alldata, pop, by = c("NAME" = "county"))

#fix NAs
alldata$NumBeds <- alldata$NumBeds %>% replace_na(0)
alldata$NumHomes <- alldata$NumHomes %>% replace_na(0)

# generate map labels and log values
alldata <- alldata %>%
  mutate(polylabels = paste0('<strong>County: </strong>', NAME,
                        '<br><strong> Number of Homes </strong>: ', NumHomes,
                        '<br><strong> Number of Beds </strong>: ', NumBeds,
                        '<br><strong> Number of Disabled Over 65 </strong>: ', numDis,
                        '<br><strong> Number of Disabled Over 65 in Poverty </strong>: ', NumPov,
                        '<br><strong> Number of Disabled Over 65 with 2 Disabilities </strong>: ', Num2Dis),
         log10bed = ifelse(NumBeds == 0, 0, log10(NumBeds)),
         log10homes = ifelse(NumHomes == 0, 0, log10(NumHomes)),
         log10dis = ifelse(numDis == 0, 0, log10(numDis)),
         bedDisRatio = ifelse(NumBeds == 0, 0, numDis / NumBeds),
         bedDisPercent = (NumBeds / numDis) * 100,
         PercentPov = (NumPov / numDis) * 100,
         Percent2Dis = (Num2Dis / numDis) * 100,
         bedDis2Percent = (NumBeds / Num2Dis) * 100,)

County Comparisons

These visualizations compare measures and a log10 version of those measures. The measures are number of homes in each county, number of beds in each county, and number of disabled over 65 in each county.

nh <- ggplot(alldata, aes(geometry = geometry)) +
  geom_sf(aes(fill = NumHomes, geometry = geometry)) +
  labs(title = "Number of Homes in Each County") +
  theme_void()

nd <- ggplot(alldata, aes(geometry = geometry)) +
  geom_sf(aes(fill = numDis, geometry = geometry)) +
  labs(title = "Number of Disabled Over 65 in Each County") +
  theme_void()

nb <- ggplot(alldata, aes(geometry = geometry)) +
  geom_sf(aes(fill = NumBeds, geometry = geometry)) +
  labs(title = "Number of Beds in Each County") +
  theme_void()

nhl <- ggplot(alldata, aes(geometry = geometry)) +
  geom_sf(aes(fill = log10homes, geometry = geometry)) +
  labs(title = "Number of Homes in Each County (Log10)") +
  theme_void()

ndl <- ggplot(alldata, aes(geometry = geometry)) +
  geom_sf(aes(fill = log10dis, geometry = geometry)) +
  labs(title = "Number of Disabled Over 65 in Each County (Log10)") +
  theme_void()

nbl <- ggplot(alldata, aes(geometry = geometry)) +
  geom_sf(aes(fill = log10bed, geometry = geometry)) +
  labs(title = "Number of Beds in Each County (Log10)") +
  theme_void()

grid.arrange(nh, nhl, ncol = 2, nrow = 1)

grid.arrange(nd, ndl, ncol = 2, nrow = 1)

grid.arrange(nb, nbl, ncol = 2, nrow = 1)

Transforming Data 2

For the next group of maps the dataset is focused on each individual long term care home. This code block fixes any data errors in the number of beds, assigns a focus of the long-term care home based on what type of beds it contains, and generates a map label.

nursinghomesgrouped <- Long_Term_Care_Nursing_Homes

# fix NA's
nursinghomesgrouped$XIX_Beds_nf_bed_count <- nursinghomesgrouped$XIX_Beds_nf_bed_count %>% replace_na(0)
nursinghomesgrouped$XVIII_Beds_nf_bed_count <- nursinghomesgrouped$XVIII_Beds_nf_bed_count %>% replace_na(0)
nursinghomesgrouped$T1819_Beds_nf_bed_count <- nursinghomesgrouped$T1819_Beds_nf_bed_count %>% replace_na(0)

# assign focus of each care home based on what type of beds they have and generate map labels
nursinghomesgrouped <- nursinghomesgrouped %>%
  mutate(type = case_when(
    XVIII_Beds_nf_bed_count > XIX_Beds_nf_bed_count & XVIII_Beds_nf_bed_count > T1819_Beds_nf_bed_count  ~ "MedicareFocus",
    XIX_Beds_nf_bed_count > XVIII_Beds_nf_bed_count & XIX_Beds_nf_bed_count >  T1819_Beds_nf_bed_count   ~ "MedicadeFocus",
    T1819_Beds_nf_bed_count > XIX_Beds_nf_bed_count & T1819_Beds_nf_bed_count > XVIII_Beds_nf_bed_count  ~ "Medicare_Medicade_Focus",
        T1819_Beds_nf_bed_count == 0 & T1819_Beds_nf_bed_count == 0 &  XVIII_Beds_nf_bed_count == 0 ~ "NoFocusListed"
  ),
  circlelabel = paste0('<strong> Name: </strong>', nf_name,
                        '<br><strong> City </strong>: ', nf_loc_city,
                        '<br><strong> Ownership </strong>: ', nf_ownership_type_desc,
                        '<br><strong> Licensee </strong>: ', nf_licensee_name,
                        '<br><strong> Total Beds </strong>: ', TOTAL_Beds_nf_bed_count))

Map 1

This map highlights the location of long term care homes and the number of beds in each county. There is very high difference between the lowest and highest number of beds in each county so custom bins are used for the map colors.

pal <- colorBin("Paired", domain = alldata$NumBeds, bins = c(0, 10, 100, 500, 1000, 2000, 3000, 4000, 5000, 6000))


leaflet(data = nursinghomesgrouped) %>% 
  addTiles() %>%
  addTiles(group = "Street View") %>%
  addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
      addPolygons(data = alldata,
              color = ~pal(alldata$NumBeds),
              weight = 3, 
              smoothFactor = 0.5,
              opacity = 1,
              fillOpacity = 0.5,
              stroke = TRUE,
              dashArray = "3",
              highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = TRUE),
              label = lapply(alldata$polylabels,  HTML)) %>%
  addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "MedicareFocus"), group = "MedicareFocus", ~Longitude, ~Latitude,
                   color = "blue", radius = 0.2) %>%
  addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "MedicadeFocus"), group = "MedicadeFocus", ~Longitude, ~Latitude,
                   color = "red", radius = 0.2) %>%
  addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "Medicare_Medicade_Focus"), group = "Medicare_Medicade_Focus", ~Longitude, ~Latitude, 
                   color = "green", radius = 0.2) %>%
    addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "NoFocusListed"), group = "NoFocusListed", ~Longitude, ~Latitude,
                     color = "black", radius = 0.2) %>%
addLayersControl(baseGroups = c("Street View", "Satellite"),
                   overlayGroups = c('MedicareFocus','MedicadeFocus', 'Medicare_Medicade_Focus', "NoFocusListed"),
                   options = layersControlOptions(collapsed = FALSE)) %>%
    addLegend("topleft",
            pal = pal, 
            values = as.numeric(alldata$NumBeds), 
            title = "Total Beds in County", 
            labFormat = labelFormat(suffix = " Beds"), 
            opacity = 1) %>%
  setView(lat = 47, lng = -120, zoom = 6)
## Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
## Need '+proj=longlat +datum=WGS84'

Map 2

This map highlights the number of beds available compared to the number of disabled over 65 living in each county along with the location of long term care homes.

pal <- colorBin("Paired", domain = alldata$bedDisPercent)

leaflet(data = nursinghomesgrouped) %>% 
  addTiles() %>%
  addTiles(group = "Street View") %>%
  addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
  addPolygons(data = alldata,
            color = ~pal(alldata$bedDisPercent ),
            weight = 3, 
            smoothFactor = 0.5,
            opacity = 0.2,
            fillOpacity = 0.4,
            stroke = TRUE,
            dashArray = "3",
            highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = FALSE),
              label = lapply(alldata$polylabels,  HTML)) %>%
  addCircleMarkers(data = g1 <- nursinghomesgrouped %>% filter(type == "MedicareFocus"), group = "MedicareFocus", ~Longitude, ~Latitude, color = "blue", 
                   radius = 1) %>%
  addCircleMarkers(data = g2 <- nursinghomesgrouped %>% filter(type == "MedicadeFocus"), group = "MedicadeFocus", ~Longitude, ~Latitude, color = "red",
                   radius = 1) %>%
  addCircleMarkers(data = g3 <- nursinghomesgrouped %>% filter(type == "Medicare_Medicade_Focus"), group = "Medicare_Medicade_Focus", ~Longitude, ~Latitude, color = "green",
                    radius = 1) %>%
  addCircleMarkers(data = g4 <- nursinghomesgrouped %>% filter(type == "NoFocusListed"), group = "NoFocusListed", ~Longitude, ~Latitude, color = "black",
                    radius = 1) %>%
addLayersControl(baseGroups = c("Street View", "Satellite"),
                   overlayGroups = c('MedicareFocus','MedicadeFocus', 'Medicare_Medicade_Focus', "NoFocusListed"),
                   options = layersControlOptions(collapsed = FALSE)) %>%
    addLegend("topleft",
            pal = pal, 
            values = as.numeric(alldata$bedDisPercent ), 
            title = "Percentage of Disabled <br>  Over 65 Able to Stay at <br> Long-Term Care in Each County", 
            labFormat = labelFormat(suffix = " %"), 
            opacity = 0.3) %>%
  setView(lat = 47, lng = -120, zoom = 6)
## Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
## Need '+proj=longlat +datum=WGS84'

Map 3

This map shows the percentage of each county’s disabled over 65 population that has two or more disabilities with the location of long term care homes.

pal <- colorBin("Paired", domain = alldata$Percent2Dis)

leaflet(data = nursinghomesgrouped) %>% 
  addTiles() %>%
  addTiles(group = "Street View") %>%
  addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
  addPolygons(data = alldata,
            color = ~pal(alldata$Percent2Dis ),
            weight = 3, 
            smoothFactor = 0.5,
            opacity = 0.2,
            fillOpacity = 0.4,
            stroke = TRUE,
            dashArray = "3",
            highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = FALSE),
              label = lapply(alldata$polylabels,  HTML)) %>%
  addCircleMarkers(data = g1 <- nursinghomesgrouped %>% filter(type == "MedicareFocus"), group = "MedicareFocus", ~Longitude, ~Latitude, color = "blue", 
                   radius = 1) %>%
  addCircleMarkers(data = g2 <- nursinghomesgrouped %>% filter(type == "MedicadeFocus"), group = "MedicadeFocus", ~Longitude, ~Latitude, color = "red",
                   radius = 1) %>%
  addCircleMarkers(data = g3 <- nursinghomesgrouped %>% filter(type == "Medicare_Medicade_Focus"), group = "Medicare_Medicade_Focus", ~Longitude, ~Latitude, color = "green",
                    radius = 1) %>%
  addCircleMarkers(data = g4 <- nursinghomesgrouped %>% filter(type == "NoFocusListed"), group = "NoFocusListed", ~Longitude, ~Latitude, color = "black",
                    radius = 1) %>%
addLayersControl(baseGroups = c("Street View", "Satellite"),
                   overlayGroups = c('MedicareFocus','MedicadeFocus', 'Medicare_Medicade_Focus', "NoFocusListed"),
                   options = layersControlOptions(collapsed = FALSE)) %>%
    addLegend("topleft",
            pal = pal, 
            values = as.numeric(alldata$Percent2Dis ), 
            title = "Percentage of Disabled <br>  Over 65 With Two or More <br> Disabilities in Each County", 
            labFormat = labelFormat(suffix = " %"), 
            opacity = 0.3) %>%
  setView(lat = 47, lng = -120, zoom = 6)
## Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
## Need '+proj=longlat +datum=WGS84'

Map 4

This map highlights the number of beds available compared to the number of disabled over 65 with two or more disabilities living in each county along with the location of long term care homes.

pal <- colorBin("Paired", domain = alldata$bedDis2Percent)

leaflet(data = nursinghomesgrouped) %>% 
  addTiles() %>%
  addTiles(group = "Street View") %>%
  addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
  addPolygons(data = alldata,
            color = ~pal(alldata$bedDis2Percent ),
            weight = 3, 
            smoothFactor = 0.5,
            opacity = 0.2,
            fillOpacity = 0.4,
            stroke = TRUE,
            dashArray = "3",
            highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = FALSE),
              label = lapply(alldata$polylabels,  HTML)) %>%
  addCircleMarkers(data = g1 <- nursinghomesgrouped %>% filter(type == "MedicareFocus"), group = "MedicareFocus", ~Longitude, ~Latitude, color = "blue", 
                   radius = 1) %>%
  addCircleMarkers(data = g2 <- nursinghomesgrouped %>% filter(type == "MedicadeFocus"), group = "MedicadeFocus", ~Longitude, ~Latitude, color = "red",
                   radius = 1) %>%
  addCircleMarkers(data = g3 <- nursinghomesgrouped %>% filter(type == "Medicare_Medicade_Focus"), group = "Medicare_Medicade_Focus", ~Longitude, ~Latitude, color = "green",
                    radius = 1) %>%
  addCircleMarkers(data = g4 <- nursinghomesgrouped %>% filter(type == "NoFocusListed"), group = "NoFocusListed", ~Longitude, ~Latitude, color = "black",
                    radius = 1) %>%
addLayersControl(baseGroups = c("Street View", "Satellite"),
                   overlayGroups = c('MedicareFocus','MedicadeFocus', 'Medicare_Medicade_Focus', "NoFocusListed"),
                   options = layersControlOptions(collapsed = FALSE)) %>%
    addLegend("topleft",
            pal = pal, 
            values = as.numeric(alldata$bedDis2Percent ), 
            title = "Percentage of Disabled <br>  Over 65 with Two or More <br> Disabilities Able  to Stay <br> at Long-Term Care in <br> Each County", 
            labFormat = labelFormat(suffix = " %"), 
            opacity = 0.3) %>%
  setView(lat = 47, lng = -120, zoom = 6)
## Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
## Need '+proj=longlat +datum=WGS84'

Map 5

This map shows the percentage of disabled over 65 in each county that are living in poverty along with the location of long term care homes.

pal <- colorBin("Paired", domain = alldata$PercentPov)

leaflet(data = nursinghomesgrouped) %>% 
  addTiles() %>%
  addTiles(group = "Street View") %>%
  addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
      addPolygons(data = alldata,
              color = ~pal(alldata$PercentPov),
              weight = 3, 
              smoothFactor = 0.5,
              opacity = 1,
              fillOpacity = 0.7,
              stroke = TRUE,
              dashArray = "3",
              highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = FALSE),
              label = lapply(alldata$polylabels,  HTML)) %>%
  addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "MedicareFocus"), group = "MedicareFocus", ~Longitude, ~Latitude,
                   color = "#9e34eb", radius = 0.2) %>%
  addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "MedicadeFocus"), group = "MedicadeFocus", ~Longitude, ~Latitude,
                   color = "#9e34eb", radius = 0.2) %>%
  addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "Medicare_Medicade_Focus"), group = "Medicare_Medicade_Focus", ~Longitude, ~Latitude,
                   color = "#9e34eb", radius = 0.2) %>%
    addCircleMarkers(data = nursinghomesgrouped %>% filter(type == "NoFocusListed"), group = "NoFocusListed", ~Longitude, ~Latitude,
                     color = "#9e34eb", radius = 0.2) %>%
addLayersControl(baseGroups = c("Street View", "Satellite"),
                    overlayGroups = c('MedicareFocus','MedicadeFocus', 'Medicare_Medicade_Focus', "NoFocusListed"),
                    options = layersControlOptions(collapsed = FALSE)) %>%
    addLegend("topleft",
            pal = pal, 
            values = as.numeric(alldata$PercentPov), 
            title = "Percent of Disabled Over 65 <br> In Poverty", 
            labFormat = labelFormat(suffix = " Percent"), 
            opacity = 1) %>%
  setView(lat = 47, lng = -120, zoom = 6)
## Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
## Need '+proj=longlat +datum=WGS84'

Map 6

This map shows the location of long term care homes and what type of home each one is.

nursinghomesgrouped %>%
  group_by(nf_ownership_type_desc) %>%
  distinct(nf_location_num, .keep_all = TRUE) %>%
  summarise(Total = n()) %>%
  arrange(desc(Total))
## # A tibble: 10 x 2
##    nf_ownership_type_desc    Total
##    <chr>                     <int>
##  1 Limited Liability Company   101
##  2 Non Profit Corporation       47
##  3 For Profit Corporation       44
##  4 State ICF/IID                 8
##  5 Limited Partnership           6
##  6 Government Agency             5
##  7 Group/ASSN                    3
##  8 Municipality                  2
##  9 Partnership                   2
## 10 Sole Proprietorship           1
leaflet(data = nursinghomesgrouped) %>% 
  addTiles() %>%
  addTiles(group = "Street View") %>%
  addCircleMarkers(data = g1 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "For Profit Corporation"), group = "For Profit Corporation", 
                   ~Longitude, ~Latitude, color = "#fff100", label = lapply(g1$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g2 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Non Profit Corporation"), group = "Non Profit Corporation",
                   ~Longitude, ~Latitude, color = "#ff8c00", label = lapply(g2$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g3 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Government Agency"), group = "Government Agency",
                   ~Longitude, ~Latitude, color = "#e81123", label = lapply(g3$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g4 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Partnership"), group = "Partnership",
                   ~Longitude, ~Latitude, color = "#ec008c", label = lapply(g4$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g5 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Group/ASSN"), group = "Group/ASSN",
                   ~Longitude, ~Latitude, color = "#68217a", label = lapply(g5$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g6 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Sole Proprietorship"), group = "Sole Proprietorship",
                   ~Longitude, ~Latitude, color = "#00188f", label = lapply(g6$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g7 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Limited Liability Company"), group = "Limited Liability Company",
                   ~Longitude, ~Latitude, color = "#00bcf2", label = lapply(g7$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g8 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "State ICF/IID"), group = "State ICF/IID",
                   ~Longitude, ~Latitude, color = "#00b294", label = lapply(g8$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g9 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Limited Partnership"), group = "Limited Partnership",
                   ~Longitude, ~Latitude, color = "#009e49", label = lapply(g9$circlelabel, HTML), radius = 1) %>%
  addCircleMarkers(data = g10 <- nursinghomesgrouped %>% filter(nf_ownership_type_desc == "Municipality"), group = "Municipality",
                   ~Longitude, ~Latitude, color = "#bad80a", label = lapply(g10$circlelabel, HTML), radius = 1) %>%
  addLegend("topright",
            colors = c("#fff100", "#ff8c00", "#e81123", "#ec008c", "#68217a", "#00188f", "#00bcf2", "#00b294", "#009e49", "#bad80a"), 
            labels = c("For Profit Corporation", "Non Profit Corporation", "Government Agency", "Partnership", "Group/ASSN", "Sole Proprietorship", 
                       "Limited Liability Company", "State ICF/IID", "Limited Partnership", "Municipality"), 
            title = "Total Beds in County", 
            labFormat = labelFormat(suffix = " Beds"), 
            opacity = 1) %>%
  setView(lat = 47, lng = -120, zoom = 6)