at_level: Census rows at one geographic level

View source: R/levels.R

at_levelR Documentation

Census rows at one geographic level

Description

The village-level 2011 tables (census_2011_demographics(), census_2011_workers(), census_2011_marginal_detail()) stack seven levels from India down to ward, and three sectors. Summing without filtering counts every population several times over. census_1981 stacks levels and sectors the same way.

Usage

at_level(data, level = "district", sector = "total")

Arguments

data

A table with a level column, such as one of the village-level 2011 tables or census_1981.

level

Geographic level, e.g. "district" or "state".

sector

"total", "rural" or "urban".

Details

India, state, district, subdistrict and village are exact: each level sums to its parent for every numeric column, and rural + urban sums to total.

"town" and "ward" are not. The census files a municipality and that same municipality plus its outgrowth as separate town rows, so the two overlap. Summing towns to their subdistrict overcounts 325 subdistricts by 73,877,047 people in total; Bengaluru's ⁠BBMP (M Corp.)⁠ and ⁠BBMP (M Corp. + OG)⁠ each carry 8,443,675. Ward rows differ from their town by 3,738,272 across 295 towns. Treat both as a lookup, not an additive slice.

Value

data filtered to that level and sector.

Examples

census_1981 |>
  at_level("state") |>
  nrow()

censusindia documentation built on Oct. 15, 2026, 5:08 p.m.