lapop R package

These are helper functions to wrangle labels and produce visualizations of ‘AmericasBarometer’ data following LAPOP Lab’s editorial guidelines.

🔗 Package website: https://lapop-central.github.io/lapop/


🛠️ Installation

To install the package in your console, run:

devtools::install_github("lapop-central/lapop", 
                         force = TRUE, 
                         build_vignettes = TRUE)

⚙️ Workflow: ‘AmericasBarometer’ Variable & Value Labels

For the full online guide, see:

📖 LAPOP Data Guide for R Users

1. Data Structure

‘AmericasBarometer’ datasets are distributed in Stata .dta format with multilingual metadata (question wording and response options) embedded as attributes. These support cross-national and longitudinal comparability.

2. Preferred Loading Method

Use:

readstata13::read.dta13()

to preserve the full metadata structure.

Other methods such as haven::read_dta() or rio::import() may fail to import the STATA attributes.

3. Variable Labels (Question Wording)

4. Value Labels (Response Options)


🎨 Workflow: ‘AmericasBarometer’ Data Visualization

📖 LAPOP Visualization Guide

  1. Load the package in R:

    library(lapop)
  2. LAPOP Lab fonts is automatically loaded, yet you can also manually if needed:

    lapop_fonts()
  3. Apply the ‘AmericasBarometer’ design effects with:

    lpr_data()
  4. Choose the appropriate lpr graph type:

  1. Store the output in an R object.

  2. Use the corresponding lapop plotting function to produce the visualization:

  1. Export the figure to your machine with:

    lapop_save()

🤝 Workflow: Contributing to the lapop R Package

  1. Fork the repository and clone it to your local machine.
  2. Create a new branch for your feature or fix.
  3. Add your new function in the R/ folder.
  4. Document the function with roxygen2 comments.
  5. Run devtools::document() to generate .Rd files in man/ and update NAMESPACE.
  6. Commit your changes and push the branch to your fork.
  7. Submit a pull request to the main repository.
  8. If you find a bug, please consider contributing to the lapop package — we spent all our money on coffee and data cleaning.