# lapop-central/lapop architecture

> Architecture diagram of the GitHub repository lapop-central/lapop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lapop-central/lapop
- Repository: https://github.com/lapop-central/lapop

## Overview

lapop is an R package for preparing AmericasBarometer data and producing LAPOP-style visualizations. Its documented workflows cover multilingual variable-label extraction and assignment, response-option labels, design-effect preparation, graph-specific data preparation and plotting, and figure export. Relationships below follow the README’s stated workflows; source excerpts were not provided, so internal calls beyond those documented are omitted.

Main entry points: [`R/lpr_hist.R`](https://github.com/lapop-central/lapop/blob/main/R/lpr_hist.R) (Prepare histogram data), [`R/lpr_cc.R`](https://github.com/lapop-central/lapop/blob/main/R/lpr_cc.R) (Prepare country comparison), [`R/lpr_ts.R`](https://github.com/lapop-central/lapop/blob/main/R/lpr_ts.R) (Prepare time series), [`R/lpr_mover.R`](https://github.com/lapop-central/lapop/blob/main/R/lpr_mover.R) (Prepare covariate breakdown)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_labels["Label workflows"]
  node_extract_notes["Extract question labels"]
  node_set_attr["Assign variable labels<br/>[lpr_set_attr.R]"]
  node_set_ros["Assign response labels<br/>[lpr_set_ros.R]"]
end

subgraph group_visualization["Visualization"]
  node_lpr_data["Apply design effects<br/>[lpr_data.R]"]
  node_lpr_hist["Prepare histogram data<br/>[lpr_hist.R]"]
  node_lpr_cc["Prepare country comparison<br/>[lpr_cc.R]"]
  node_lpr_ts["Prepare time series<br/>[lpr_ts.R]"]
  node_lpr_mover["Prepare covariate breakdown<br/>[lpr_mover.R]"]
  node_lapop_hist["Plot histogram<br/>[lapop_hist.R]"]
  node_lapop_cc["Plot country comparison<br/>[lapop_cc.R]"]
  node_lapop_ts["Plot time series<br/>[lapop_ts.R]"]
  node_lapop_mover["Plot covariate breakdown<br/>[lapop_mover.R]"]
end

subgraph group_presentation["Presentation"]
  node_fonts["Load LAPOP fonts<br/>[lapop_fonts.R]"]
  node_save["Export figure<br/>[lapop_save.R]"]
end

node_analyst(("R user"))
node_stata["Stata data"]

node_analyst -->|"loads data"| node_stata
node_stata -->|"provides metadata"| node_extract_notes
node_analyst -->|"extracts labels"| node_extract_notes
node_analyst -->|"assigns labels"| node_set_attr
node_analyst -->|"assigns response labels"| node_set_ros
node_analyst -->|"applies effects"| node_lpr_data
node_analyst -->|"chooses graph type"| node_lpr_hist
node_analyst -->|"chooses graph type"| node_lpr_cc
node_analyst -->|"chooses graph type"| node_lpr_ts
node_analyst -->|"chooses graph type"| node_lpr_mover
node_lpr_hist -->|"plots prepared data"| node_lapop_hist
node_lpr_cc -->|"plots prepared data"| node_lapop_cc
node_lpr_ts -->|"plots prepared data"| node_lapop_ts
node_lpr_mover -->|"plots prepared data"| node_lapop_mover
node_analyst -->|"loads fonts"| node_fonts
node_analyst -->|"exports figure"| node_save

click node_extract_notes "https://github.com/lapop-central/lapop/blob/main/R/lpr_extract_notes.R"
click node_set_attr "https://github.com/lapop-central/lapop/blob/main/R/lpr_set_attr.R"
click node_set_ros "https://github.com/lapop-central/lapop/blob/main/R/lpr_set_ros.R"
click node_lpr_data "https://github.com/lapop-central/lapop/blob/main/R/lpr_data.R"
click node_lpr_hist "https://github.com/lapop-central/lapop/blob/main/R/lpr_hist.R"
click node_lpr_cc "https://github.com/lapop-central/lapop/blob/main/R/lpr_cc.R"
click node_lpr_ts "https://github.com/lapop-central/lapop/blob/main/R/lpr_ts.R"
click node_lpr_mover "https://github.com/lapop-central/lapop/blob/main/R/lpr_mover.R"
click node_lapop_hist "https://github.com/lapop-central/lapop/blob/main/R/lapop_hist.R"
click node_lapop_cc "https://github.com/lapop-central/lapop/blob/main/R/lapop_cc.R"
click node_lapop_ts "https://github.com/lapop-central/lapop/blob/main/R/lapop_ts.R"
click node_lapop_mover "https://github.com/lapop-central/lapop/blob/main/R/lapop_mover.R"
click node_fonts "https://github.com/lapop-central/lapop/blob/main/R/lapop_fonts.R"
click node_save "https://github.com/lapop-central/lapop/blob/main/R/lapop_save.R"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_extract_notes,node_set_attr,node_set_ros,node_analyst toneBlue
class node_lpr_data,node_lpr_hist,node_lpr_cc,node_lpr_ts,node_lpr_mover,node_lapop_hist,node_lapop_cc,node_lapop_ts,node_lapop_mover toneAmber
class node_fonts,node_save toneMint
class node_stata toneIndigo
```

## Components

### Label workflows

- [Extract question labels](https://github.com/lapop-central/lapop/blob/main/R/lpr_extract_notes.R): `R/lpr_extract_notes.R`
- [Assign variable labels](https://github.com/lapop-central/lapop/blob/main/R/lpr_set_attr.R): `R/lpr_set_attr.R`
- [Assign response labels](https://github.com/lapop-central/lapop/blob/main/R/lpr_set_ros.R): `R/lpr_set_ros.R`

### Visualization

- [Apply design effects](https://github.com/lapop-central/lapop/blob/main/R/lpr_data.R): `R/lpr_data.R`
- [Prepare histogram data](https://github.com/lapop-central/lapop/blob/main/R/lpr_hist.R): `R/lpr_hist.R`
- [Prepare country comparison](https://github.com/lapop-central/lapop/blob/main/R/lpr_cc.R): `R/lpr_cc.R`
- [Prepare time series](https://github.com/lapop-central/lapop/blob/main/R/lpr_ts.R): `R/lpr_ts.R`
- [Prepare covariate breakdown](https://github.com/lapop-central/lapop/blob/main/R/lpr_mover.R): `R/lpr_mover.R`
- [Plot histogram](https://github.com/lapop-central/lapop/blob/main/R/lapop_hist.R): `R/lapop_hist.R`
- [Plot country comparison](https://github.com/lapop-central/lapop/blob/main/R/lapop_cc.R): `R/lapop_cc.R`
- [Plot time series](https://github.com/lapop-central/lapop/blob/main/R/lapop_ts.R): `R/lapop_ts.R`
- [Plot covariate breakdown](https://github.com/lapop-central/lapop/blob/main/R/lapop_mover.R): `R/lapop_mover.R`

### Presentation

- [Load LAPOP fonts](https://github.com/lapop-central/lapop/blob/main/R/lapop_fonts.R): `R/lapop_fonts.R`
- [Export figure](https://github.com/lapop-central/lapop/blob/main/R/lapop_save.R): `R/lapop_save.R`

### Other components

- **R user**
- **Stata data**

## Connections

- R user → Stata data: loads data (evidence: `README.md`)
- Stata data → Extract question labels: provides metadata (evidence: `README.md`)
- R user → Extract question labels: extracts labels (evidence: `README.md`)
- R user → Assign variable labels: assigns labels (evidence: `README.md`)
- R user → Assign response labels: assigns response labels (evidence: `README.md`)
- R user → Apply design effects: applies effects (evidence: `README.md`)
- R user → Prepare histogram data: chooses graph type (evidence: `README.md`)
- R user → Prepare country comparison: chooses graph type (evidence: `README.md`)
- R user → Prepare time series: chooses graph type (evidence: `README.md`)
- R user → Prepare covariate breakdown: chooses graph type (evidence: `README.md`)
- Prepare histogram data → Plot histogram: plots prepared data (evidence: `README.md`)
- Prepare country comparison → Plot country comparison: plots prepared data (evidence: `README.md`)
- Prepare time series → Plot time series: plots prepared data (evidence: `README.md`)
- Prepare covariate breakdown → Plot covariate breakdown: plots prepared data (evidence: `README.md`)
- R user → Load LAPOP fonts: loads fonts (evidence: `README.md`)
- R user → Export figure: exports figure (evidence: `README.md`)
