Introduction
The aim is to explore how Maryland communities engage in key preventive health measures, use visualizations to uncover patterns in participation and highlight potential gaps in public health outreach.
caption = “Source: Centers for Disease Control and Prevention (CDC)” https://www.cdc.gov/places/about/500-cities-2016-2019/ ## Load the libraries and set the working directory
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.2 ✔ tibble 3.3.0
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.0.4
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Loading required package: viridisLite
setwd ("C:/Users/tmats/OneDrive/DATA110/Working Directories" )
cities500 <- read_csv ("500CitiesLocalHealthIndicators.cdc.csv" )
Rows: 810103 Columns: 24
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (17): StateAbbr, StateDesc, CityName, GeographicLevel, DataSource, Categ...
dbl (6): Year, Data_Value, Low_Confidence_Limit, High_Confidence_Limit, Cit...
num (1): PopulationCount
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Warning in data(cities500): data set 'cities500' not found
Filter the dataset
Remove the StateDesc that includes the United Sates, select Prevention as the category (of interest), filter for only measuring crude prevalence and select only 2017.
lat_long_md <- lat_long |>
filter (StateDesc != "United State" ) |>
filter (Data_Value_Type == "Crude prevalence" ) |>
filter (Year == 2017 ) |>
filter (StateAbbr == "MD" ) |>
filter (Category == "Prevention" )
head (lat_long_md)
# A tibble: 6 × 25
Year StateAbbr StateDesc CityName GeographicLevel DataSource Category
<dbl> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 MD Maryland Baltimore Census Tract BRFSS Prevention
2 2017 MD Maryland Baltimore Census Tract BRFSS Prevention
3 2017 MD Maryland Baltimore Census Tract BRFSS Prevention
4 2017 MD Maryland Baltimore Census Tract BRFSS Prevention
5 2017 MD Maryland Baltimore Census Tract BRFSS Prevention
6 2017 MD Maryland Baltimore Census Tract BRFSS Prevention
# ℹ 18 more variables: UniqueID <chr>, Measure <chr>, Data_Value_Unit <chr>,
# DataValueTypeID <chr>, Data_Value_Type <chr>, Data_Value <dbl>,
# Low_Confidence_Limit <dbl>, High_Confidence_Limit <dbl>,
# Data_Value_Footnote_Symbol <chr>, Data_Value_Footnote <chr>,
# PopulationCount <dbl>, lat <dbl>, long <dbl>, CategoryID <chr>,
# MeasureId <chr>, CityFIPS <dbl>, TractFIPS <dbl>, Short_Question_Text <chr>
md_clean1 <- lat_long_md |>
select (- DataSource, - Data_Value_Unit, - DataValueTypeID, - Low_Confidence_Limit, - High_Confidence_Limit, - Data_Value_Footnote,)
head (md_clean1)
# A tibble: 6 × 19
Year StateAbbr StateDesc CityName GeographicLevel Category UniqueID Measure
<dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Chole…
2 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Visit…
3 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Visit…
4 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Curre…
5 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Curre…
6 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Visit…
# ℹ 11 more variables: Data_Value_Type <chr>, Data_Value <dbl>,
# Data_Value_Footnote_Symbol <chr>, PopulationCount <dbl>, lat <dbl>,
# long <dbl>, CategoryID <chr>, MeasureId <chr>, CityFIPS <dbl>,
# TractFIPS <dbl>, Short_Question_Text <chr>
Create subset not more than 900 observations
md_clean1 |>
filter (! is.na (PopulationCount), ! is.na (Data_Value))
# A tibble: 800 × 19
Year StateAbbr StateDesc CityName GeographicLevel Category UniqueID Measure
<dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Chole…
2 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Visit…
3 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Visit…
4 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
5 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
6 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Visit…
7 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
8 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Takin…
9 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
10 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Chole…
# ℹ 790 more rows
# ℹ 11 more variables: Data_Value_Type <chr>, Data_Value <dbl>,
# Data_Value_Footnote_Symbol <chr>, PopulationCount <dbl>, lat <dbl>,
# long <dbl>, CategoryID <chr>, MeasureId <chr>, CityFIPS <dbl>,
# TractFIPS <dbl>, Short_Question_Text <chr>
md_clean1 |>
filter (! is.na (Data_Value))
# A tibble: 800 × 19
Year StateAbbr StateDesc CityName GeographicLevel Category UniqueID Measure
<dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Chole…
2 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Visit…
3 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Visit…
4 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
5 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
6 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Visit…
7 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
8 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Takin…
9 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Curre…
10 2017 MD Maryland Baltimore Census Tract Prevent… 2404000… "Chole…
# ℹ 790 more rows
# ℹ 11 more variables: Data_Value_Type <chr>, Data_Value <dbl>,
# Data_Value_Footnote_Symbol <chr>, PopulationCount <dbl>, lat <dbl>,
# long <dbl>, CategoryID <chr>, MeasureId <chr>, CityFIPS <dbl>,
# TractFIPS <dbl>, Short_Question_Text <chr>
##Based on the GIS tutorial (Japan earthquakes), create one plot about something in your subsetted dataset
ggplot (md_clean1, aes (x = Short_Question_Text, y = Data_Value, fill = Short_Question_Text)) +
geom_bar (stat = "identity" , width = 0.7 ) +
geom_text (aes (label= Data_Value), vjust= 2.5 , hjust= 0.5 , size = 3 , color= "white" ) +
scale_fill_viridis (discrete = TRUE , option = "D" ) +
labs ( x = NULL ,
caption = 'Source:Centers for Disease Control and Prevention (CDC)' )
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_bar()`).
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_text()`).
theme_minimal () +
ggtitle ("Health Prevention Behaviors Among Maryland Adults" )
List of 136
$ line :List of 6
..$ colour : chr "black"
..$ linewidth : num 0.5
..$ linetype : num 1
..$ lineend : chr "butt"
..$ arrow : logi FALSE
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_line" "element"
$ rect :List of 5
..$ fill : chr "white"
..$ colour : chr "black"
..$ linewidth : num 0.5
..$ linetype : num 1
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_rect" "element"
$ text :List of 11
..$ family : chr ""
..$ face : chr "plain"
..$ colour : chr "black"
..$ size : num 11
..$ hjust : num 0.5
..$ vjust : num 0.5
..$ angle : num 0
..$ lineheight : num 0.9
..$ margin : 'margin' num [1:4] 0points 0points 0points 0points
.. ..- attr(*, "unit")= int 8
..$ debug : logi FALSE
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ title : chr "Health Prevention Behaviors Among Maryland Adults"
$ aspect.ratio : NULL
$ axis.title : NULL
$ axis.title.x :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : NULL
..$ vjust : num 1
..$ angle : NULL
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 2.75points 0points 0points 0points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.title.x.top :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : NULL
..$ vjust : num 0
..$ angle : NULL
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 0points 0points 2.75points 0points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.title.x.bottom : NULL
$ axis.title.y :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : NULL
..$ vjust : num 1
..$ angle : num 90
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 0points 2.75points 0points 0points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.title.y.left : NULL
$ axis.title.y.right :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : NULL
..$ vjust : num 1
..$ angle : num -90
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 0points 0points 0points 2.75points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.text :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : chr "grey30"
..$ size : 'rel' num 0.8
..$ hjust : NULL
..$ vjust : NULL
..$ angle : NULL
..$ lineheight : NULL
..$ margin : NULL
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.text.x :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : NULL
..$ vjust : num 1
..$ angle : NULL
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 2.2points 0points 0points 0points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.text.x.top :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : NULL
..$ vjust : num 0
..$ angle : NULL
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 0points 0points 2.2points 0points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.text.x.bottom : NULL
$ axis.text.y :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : num 1
..$ vjust : NULL
..$ angle : NULL
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 0points 2.2points 0points 0points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.text.y.left : NULL
$ axis.text.y.right :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : num 0
..$ vjust : NULL
..$ angle : NULL
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 0points 0points 0points 2.2points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.text.theta : NULL
$ axis.text.r :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : num 0.5
..$ vjust : NULL
..$ angle : NULL
..$ lineheight : NULL
..$ margin : 'margin' num [1:4] 0points 2.2points 0points 2.2points
.. ..- attr(*, "unit")= int 8
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.ticks : list()
..- attr(*, "class")= chr [1:2] "element_blank" "element"
$ axis.ticks.x : NULL
$ axis.ticks.x.top : NULL
$ axis.ticks.x.bottom : NULL
$ axis.ticks.y : NULL
$ axis.ticks.y.left : NULL
$ axis.ticks.y.right : NULL
$ axis.ticks.theta : NULL
$ axis.ticks.r : NULL
$ axis.minor.ticks.x.top : NULL
$ axis.minor.ticks.x.bottom : NULL
$ axis.minor.ticks.y.left : NULL
$ axis.minor.ticks.y.right : NULL
$ axis.minor.ticks.theta : NULL
$ axis.minor.ticks.r : NULL
$ axis.ticks.length : 'simpleUnit' num 2.75points
..- attr(*, "unit")= int 8
$ axis.ticks.length.x : NULL
$ axis.ticks.length.x.top : NULL
$ axis.ticks.length.x.bottom : NULL
$ axis.ticks.length.y : NULL
$ axis.ticks.length.y.left : NULL
$ axis.ticks.length.y.right : NULL
$ axis.ticks.length.theta : NULL
$ axis.ticks.length.r : NULL
$ axis.minor.ticks.length : 'rel' num 0.75
$ axis.minor.ticks.length.x : NULL
$ axis.minor.ticks.length.x.top : NULL
$ axis.minor.ticks.length.x.bottom: NULL
$ axis.minor.ticks.length.y : NULL
$ axis.minor.ticks.length.y.left : NULL
$ axis.minor.ticks.length.y.right : NULL
$ axis.minor.ticks.length.theta : NULL
$ axis.minor.ticks.length.r : NULL
$ axis.line : list()
..- attr(*, "class")= chr [1:2] "element_blank" "element"
$ axis.line.x : NULL
$ axis.line.x.top : NULL
$ axis.line.x.bottom : NULL
$ axis.line.y : NULL
$ axis.line.y.left : NULL
$ axis.line.y.right : NULL
$ axis.line.theta : NULL
$ axis.line.r : NULL
$ legend.background : list()
..- attr(*, "class")= chr [1:2] "element_blank" "element"
$ legend.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
..- attr(*, "unit")= int 8
$ legend.spacing : 'simpleUnit' num 11points
..- attr(*, "unit")= int 8
$ legend.spacing.x : NULL
$ legend.spacing.y : NULL
$ legend.key : list()
..- attr(*, "class")= chr [1:2] "element_blank" "element"
$ legend.key.size : 'simpleUnit' num 1.2lines
..- attr(*, "unit")= int 3
$ legend.key.height : NULL
$ legend.key.width : NULL
$ legend.key.spacing : 'simpleUnit' num 5.5points
..- attr(*, "unit")= int 8
$ legend.key.spacing.x : NULL
$ legend.key.spacing.y : NULL
$ legend.frame : NULL
$ legend.ticks : NULL
$ legend.ticks.length : 'rel' num 0.2
$ legend.axis.line : NULL
$ legend.text :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : 'rel' num 0.8
..$ hjust : NULL
..$ vjust : NULL
..$ angle : NULL
..$ lineheight : NULL
..$ margin : NULL
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ legend.text.position : NULL
$ legend.title :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : num 0
..$ vjust : NULL
..$ angle : NULL
..$ lineheight : NULL
..$ margin : NULL
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ legend.title.position : NULL
$ legend.position : chr "right"
$ legend.position.inside : NULL
$ legend.direction : NULL
$ legend.byrow : NULL
$ legend.justification : chr "center"
$ legend.justification.top : NULL
$ legend.justification.bottom : NULL
$ legend.justification.left : NULL
$ legend.justification.right : NULL
$ legend.justification.inside : NULL
$ legend.location : NULL
$ legend.box : NULL
$ legend.box.just : NULL
$ legend.box.margin : 'margin' num [1:4] 0cm 0cm 0cm 0cm
..- attr(*, "unit")= int 1
$ legend.box.background : list()
..- attr(*, "class")= chr [1:2] "element_blank" "element"
$ legend.box.spacing : 'simpleUnit' num 11points
..- attr(*, "unit")= int 8
[list output truncated]
- attr(*, "class")= chr [1:2] "theme" "gg"
- attr(*, "complete")= logi TRUE
- attr(*, "validate")= logi TRUE
##Now create a map of your subsetted dataset. First map chunk here Annual Checkup subset
Attaching package: 'maps'
The following object is masked from 'package:viridis':
unemp
The following object is masked from 'package:purrr':
map
Linking to GEOS 3.13.1, GDAL 3.11.0, PROJ 9.6.0; sf_use_s2() is TRUE
Subset_prevention <- md_clean1 |>
filter (Short_Question_Text == "Annual Checkup" )
leaflet (data = Subset_prevention) |>
addProviderTiles ("OpenStreetMap" ) |>
setView (lng = - 76.6413 , lat = 39.0458 , zoom = 11 ) |>
addCircleMarkers (lng = ~ long,
lat = ~ lat,
radius = ~ sqrt (PopulationCount) / 10 , # Adjust denominator as needed for better scaling
color = "dodgerblue" ,stroke = TRUE ,
weight = 1 ,
fillOpacity = 0.7 )
Brief Essay
The bar chart compares the prevalence of four preventive health measures, namely, annual Checkup, Cholesterol Screening, Health Insurance Coverage, and Blood Pressure Medication use. The tallest bar appeared to be Cholesterol screening followed by BP Medication usage, signaling strong participation in these essential health behaviors. In contrast, Health Insurance coverage, while fundamental, shows comparatively lower representation, raising questions about accessibility or reporting within this subset.Maps paint a vivid picture of how different communities across Maryland are participating in annual checkups. Each circle represents a population cluster, with larger circles indicating higher numbers of individuals reporting annual medical visits. By visualizing these categories side by side, the graph shines a light on where public health outreach might be thriving and where it could be reinforced. By visualizing these categories side by side, the graph shines a light on where public health outreach might be thriving and where it could be reinforced.