Returns a tidy tibble from the bundled MCCD Parquet files via DuckDB.
All tables are stored in long format: state-wide tables (T2-T4) have a
State column; age-disaggregated tables (T5-T7) have an Age_Group column.
Usage
get_mccd(
table = c("deaths", "deaths_pct", "cause", "age", "subcause", "state_subcause"),
cause = NULL,
state = NULL,
year = NULL,
sex = NULL,
geometry = FALSE
)Arguments
- table
Character. Which table to query. One of:
"deaths": Table 2, state-wise absolute death counts"deaths_pct": Table 3, state-wise death percentages"cause": Table 4, state-level deaths by major cause"age": Table 5, India-level age-disaggregated deaths"subcause": Table 6, India-level detailed sub-cause deaths"state_subcause": Table 7, state+age disaggregated deaths
- cause
Character or
NULL. Case-insensitive regex applied toCause_Of_DeathORICD10_Code. E.g.cause = "I20"matches I20, I200, I209.cause = "coronary"matches any cause containing "coronary". Ignored (with a warning) fortable = "deaths"or"deaths_pct"since those tables aggregate across all causes.- state
Character vector or
NULL. State name(s) to filter. Accepts canonical names, common variants, ALLCAPS forms, and R column name forms. Use"All States (Total)"for the national aggregate. Unrecognized names return 0 rows with a warning. Ignored for tables without aStatecolumn ("age","subcause").- year
Integer vector or
NULL. Years to include (e.g.2015:2020).NULLreturns all available years. Unavailable years (e.g. Table 2, 2011) return 0 rows silently.- sex
Character or
NULL. One of"T"(total),"M"(male),"F"(female). Case-insensitive.NULLreturns all three rows per record.- geometry
Logical. If
TRUE, attach LGD state boundaries to the result (requires thesfpackage). Only applies to tables with aStatecolumn. DefaultFALSE.
Value
A tibble with the common columns year,
Major_Group, Minor_Group, Cause_Of_Death, ICD10_Code, Sex, plus
table-specific columns (State or Age_Group, and Deaths or Percent).
If geometry = TRUE, an sf object.
Examples
if (FALSE) { # \dontrun{
# All cardiovascular deaths by state, 2015-2020
get_mccd(table = "cause", cause = "IX.", year = 2015:2020, sex = "T")
# Age distribution of infectious disease deaths, all years
get_mccd(table = "age", cause = "I\\.", sex = "T")
# State-wise counts for Kerala, 2018-2022
get_mccd(table = "deaths", state = "Kerala", year = 2018:2022)
# Choropleth-ready: CV deaths by state with geometry
get_mccd(
table = "cause", cause = "IX\\.", sex = "T",
year = 2020, geometry = TRUE
)
} # }