-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsenior.Rmd
45 lines (35 loc) · 1.32 KB
/
senior.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
title: "Senior Citizen Concentration"
output: html_document
date: '2022-06-30'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(tidycensus)
library(ggthemes)
library(tigris)
```
Senior citizens in the U.S are citizens who are at least 65 years old. The plot below visualizes the percentage of senior citizens in the states of Washington, Oregen, and Idaho(Northwestern States).
```{r warning = FALSE, include = FALSE}
nw_states <- c("OR", "WA", "ID")
nw_pums <- get_pums(variables = c("AGEP", "PUMA"), state = nw_states, recode = TRUE, survey = "acs1", year = 2018)
nw_Senior <- nw_pums|>
group_by(ST, PUMA)|>
summarize(total_pop = sum(PWGTP),
pct_Senior = sum(PWGTP[AGEP > 64]) / total_pop,
.groups = "drop")
nw_pumas <- map(nw_states, tigris::pumas, class="sf", cb=TRUE, year = 2018) |> reduce(rbind)
nw_final <- nw_pumas %>%
left_join(nw_Senior, by = c("STATEFP10" = "ST", PUMACE10 = "PUMA"))
```
```{r warning = FALSE}
nw_final |>
ggplot(aes(fill = pct_Senior)) +
geom_sf() +
scale_fill_viridis_b(name = NULL, option = "magma", labels = scales::label_percent(1)) +
theme_void() +
labs(title = "Percentage of Population made up by Seniors",
subtitle = "Location: U.S Northwest",
caption = "American Community Survey 2014-18")
```