Labeling, weighting, and plotting data following custom style guidelines for use in reports, presentations, and social media posts. The Center for Global Democracy (formerly the Latin American Public Opinion Project) at Vanderbilt University is a leader in public survey research, best known for the Americas Barometer project. The publicly available data can be downloaded from: < https://www.vanderbilt.edu/cgd/data-access/>.
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/
To install the package from CRAN in your console, run:
install.packages(lapop)
For the most recent version, please use:
pak::pak("lapop-central/lapop")
### OR
devtools::install_github("lapop-central/lapop", force = TRUE)
For the full online guide, see:
📖 LAPOP Data Guide for R Users
'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.
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.
expansion.fields attribute.lpr_extract_notes() to convert into a tidy data frame.lpr_set_attr() using the appropriate noteid.label.table attribute.lpr_set_ros() to assign these response labels in English, Spanish, or Portuguese.Load the package in R:
library(lapop)
LAPOP Lab fonts is automatically loaded, yet you can also manually if needed:
lapop_fonts()
Apply the 'AmericasBarometer' design effects with:
lpr_data()
Choose the appropriate lpr graph type:
lpr_hist()lpr_cc()lpr_ts()lpr_mover()5. Store the output in an R object.
File names: .csv and graphics files should have the same name. Their names should be in the following standard format: CountryYear_DVcode(s)_IVcode(s)_graphtype.extension
Examples:
There will be some cases that do not easily fit this standard. Use your best judgment.
Use the corresponding lapop plotting function to produce the visualization:
lapop_hist(), lapop_cc(), lapop_ts(), etc.7. Export the figure to your machine with:
lapop_save()
lapop R PackageCreate a new branch for your feature or bug fix.
Document exported functions with roxygen2 comments. Add or update tests in tests/testthat/.
Commit your changes and push the branch to your fork. Submit a pull request with a clear description of the change.
R/ folder.devtools::document() to update NAMESPACE and man/.devtools::test() and devtools::check()If you find a bug, please consider contributing to the lapop package — we spent all our money on coffee, empanadas, and data cleaning.