library(indiacensus)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggplot2)
State population
years <- c(1941, 1951, 1961, 1971, 1981, 1991, 2001, 2011)
pop_geo <- lapply(years, function(y) {
census_population_time_series |>
filter(geography == "state", year == y) |>
attach_geometry(year = y, geography = "state")
}) |> bind_rows()

Decadal growth rate
growth_years <- c(1951, 1961, 1971, 1981, 1991, 2001, 2011)
pop <- census_population_time_series |>
filter(geography == "state") |>
arrange(state_name, year)
growth <- pop |>
group_by(state_name) |>
mutate(growth_rate = 100 * (population - lag(population)) / lag(population)) |>
filter(!is.na(growth_rate), year %in% growth_years) |>
ungroup()
growth_geo <- lapply(growth_years, function(y) {
growth |>
filter(year == y) |>
attach_geometry(year = y, geography = "state")
}) |> bind_rows()
