Skip to content

Commit e97f7ee

Browse files
committed
Fix years
1 parent 1695983 commit e97f7ee

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

vignettes/population-maps.Rmd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ library(ggplot2)
2525
## State Population Over Time
2626

2727
```{r data}
28-
years <- seq(1901, 2011, by = 10)
28+
years <- c(1941, 1951, 1961, 1971, 1981, 1991, 2001, 2011)
2929
3030
pop_geo <- lapply(years, function(y) {
3131
census_population_time_series |>
@@ -46,17 +46,19 @@ ggplot(pop_geo) +
4646
## Decadal Growth Rate
4747

4848
```{r growth}
49+
growth_years <- c(1951, 1961, 1971, 1981, 1991, 2001, 2011)
50+
4951
pop <- census_population_time_series |>
5052
filter(geography == "state") |>
5153
arrange(state_name, year)
5254
5355
growth <- pop |>
5456
group_by(state_name) |>
5557
mutate(growth_rate = 100 * (population - lag(population)) / lag(population)) |>
56-
filter(!is.na(growth_rate)) |>
58+
filter(!is.na(growth_rate), year %in% growth_years) |>
5759
ungroup()
5860
59-
growth_geo <- lapply(unique(growth$year), function(y) {
61+
growth_geo <- lapply(growth_years, function(y) {
6062
growth |>
6163
filter(year == y) |>
6264
attach_geometry(year = y, geography = "state")

0 commit comments

Comments
 (0)