Learn R Programming

decompositionLE (version 1.0.0)

plot_disease: Title plot_disease

Description

Visualize disease-related deltas from a data frame. It pivots columns starting with "delta" and ending with user-specified suffixes (e.g., c("CD", "NCD", "Injuries")) into a long format and creates a formatted stacked bar plot.

Usage

plot_disease(x, suffixes, nDx, line = TRUE)

Value

A ggplot object showing disease breakdown values

Arguments

x

A data frame containing decomp_disease() output.

suffixes

A character vector of disease suffixes to match (e.g., c("CD", "NCD", "Injuries")). Essentially the same as diseases argument in decomp_disease().

nDx

Column name for contribution of all-cause mortality differences in groups 1 and 2 in age groups x to x + n.

line

Logical for additional line geom showing total effect. TRUE by default.

Details

Plot disease decomposition breakdown

Examples

Run this code

disease_data <- decomp_disease(india_china_males_1990,
  breakdown = "proportion", age_col = "Age", diseases = c("CD", "NCD", "Injuries"),
  group_1 = "India", group_1_m = "India_nmx", group_2 = "China",
  group_2_m = "China_nmx", nDx = "nDx"
)

plot_disease(disease_data, c("delta_CD", "delta_NCD", "delta_Injuries"), "nDx", line = FALSE)
plot_disease(disease_data, c("delta_CD", "delta_NCD", "delta_Injuries"), "nDx", line = TRUE)

Run the code above in your browser using DataLab