| Title: | Access the Bangladesh Environmental Mobility Panel Dataset |
|---|---|
| Description: | Provides functions to download and work with the Bangladesh Environmental Mobility Panel (BEMP), a household panel survey tracing the impacts of riverbank erosion and flooding on (im)mobility, socio-economic outcomes, and political attitudes along the Jamuna River in Bangladesh (2021-2024). Wave datasets (20 files across 14 survey rounds) are hosted on Zenodo (<doi:10.5281/zenodo.18229497>) and downloaded on demand with local caching. Bundled data include a merged cross-wave codebook and wave metadata. |
| Authors: | Jan Freihardt [aut, cre] |
| Maintainer: | Jan Freihardt <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.3 |
| Built: | 2026-06-01 08:32:27 UTC |
| Source: | https://github.com/janfreihardt/bempdata |
Deletes all locally cached BEMP files. The next call to get_wave() or
get_codebook() will re-download from Zenodo.
bemp_cache_clear(confirm = FALSE)bemp_cache_clear(confirm = FALSE)
confirm |
Logical. Set to |
Invisibly returns TRUE if the cache was cleared, FALSE if
the user declined.
if (interactive()) { bemp_cache_clear(confirm = TRUE) }if (interactive()) { bemp_cache_clear(confirm = TRUE) }
Reports the location and size of the local cache directory where downloaded BEMP files are stored.
bemp_cache_info()bemp_cache_info()
Invisibly returns the cache directory path. Called for its side effect of printing cache information.
bemp_cache_info()bemp_cache_info()
A data frame containing the combined codebook for all 20 BEMP wave datasets.
Each row describes one variable in one wave. Built from the per-wave codebook
CSV files hosted on Zenodo; regenerate with source("data-raw/build_data.R").
codebookcodebook
A data frame with one row per variable per wave. Key columns:
wave: Wave identifier, e.g. "w1", "w6_m", "w14_v".
variable_name: Variable name as it appears in the dataset.
variable_label: Short English label for the variable.
block: Thematic block within the questionnaire.
question: Short question description.
question_type: Question type (e.g. single-choice, numeric).
question_text: Full question text in English.
question_text_bn: Full question text in Bangla.
appears_in_waves: String listing all waves in which this variable
appears, with observation counts.
Additional columns val_0, val_1, ... contain English value labels for
coded response options; 0_bn, 1_bn, ... contain the corresponding
Bangla value labels. Other columns include item_source, item_text,
item_text_bn, skip_logic, block_display_logic,
block_randomization, question_display_logic, comment, and
dataset.
Zenodo (concept DOI 10.5281/zenodo.18229497), bemp_codebooks_as_csv.zip
Returns the codebook for a specific wave, or the merged codebook across all waves. Codebooks are downloaded from Zenodo on first use (~4 MB) and cached locally. Alternatively, use the pre-built codebook object that ships with the package for offline use.
get_codebook(wave = "all", refresh = FALSE)get_codebook(wave = "all", refresh = FALSE)
wave |
Character. Wave identifier (e.g. |
refresh |
Logical. Re-download from Zenodo even if already cached.
Default |
A tibble with one row per variable. Key columns:
wave: wave identifier
variable_name, variable_label
block, question, question_type
question_text, question_text_bn (Bangla)
appears_in_waves: cross-wave appearance string
Value label columns (val_0, val_1, ...)
# Use a temporary cache so downloaded files are cleaned up after the session old_cache <- Sys.getenv("BEMPDATADIR") Sys.setenv(BEMPDATADIR = file.path(tempdir(), "BEMPdata")) # Codebook for the baseline wave cb_w1 <- get_codebook("w1") # Merged codebook (all waves) cb_all <- get_codebook() Sys.setenv(BEMPDATADIR = old_cache)# Use a temporary cache so downloaded files are cleaned up after the session old_cache <- Sys.getenv("BEMPDATADIR") Sys.setenv(BEMPDATADIR = file.path(tempdir(), "BEMPdata")) # Codebook for the baseline wave cb_w1 <- get_codebook("w1") # Merged codebook (all waves) cb_all <- get_codebook() Sys.setenv(BEMPDATADIR = old_cache)
Downloads the requested wave dataset from Zenodo on first use and returns it as a tibble. All wave files share a single zip archive per format, so the first call downloads every wave at once (~6 MB for CSV, ~14 MB for Stata); subsequent calls are instant because files are cached locally.
get_wave(wave, format = "csv", refresh = FALSE)get_wave(wave, format = "csv", refresh = FALSE)
wave |
Character. Wave identifier. Use lowercase with an underscore
suffix for migrant ( |
format |
Character. |
refresh |
Logical. Re-download from Zenodo even if already cached.
Default |
A tibble with one row per survey respondent.
# Use a temporary cache so downloaded files are cleaned up after the session old_cache <- Sys.getenv("BEMPDATADIR") Sys.setenv(BEMPDATADIR = file.path(tempdir(), "BEMPdata")) # Baseline in-person wave w1 <- get_wave("w1") # Wave 6, migrant questionnaire (accepts upper or lower case) w6m <- get_wave("w6_M") # Village profile, Wave 14, in Stata format with value labels w14v <- get_wave("w14_V", format = "dta") Sys.setenv(BEMPDATADIR = old_cache)# Use a temporary cache so downloaded files are cleaned up after the session old_cache <- Sys.getenv("BEMPDATADIR") Sys.setenv(BEMPDATADIR = file.path(tempdir(), "BEMPdata")) # Baseline in-person wave w1 <- get_wave("w1") # Wave 6, migrant questionnaire (accepts upper or lower case) w6m <- get_wave("w6_M") # Village profile, Wave 14, in Stata format with value labels w14v <- get_wave("w14_V", format = "dta") Sys.setenv(BEMPDATADIR = old_cache)
Searches the bundled codebook for variables whose name, label, or question text matches a pattern. Useful for finding a variable when you know a keyword but not the exact variable name.
lookup_variable(pattern, fields = c("name", "label", "question"))lookup_variable(pattern, fields = c("name", "label", "question"))
pattern |
Character. A regular expression (case-insensitive). For
simple keyword searches just supply a word, e.g. |
fields |
Character vector. Which fields to search. One or more of
|
A tibble with columns wave, variable_name, variable_label,
block, and question for all matching variables, sorted by wave.
# Find all income-related variables lookup_variable("income") # Search only variable labels for migration-related items lookup_variable("migrat", fields = "label")# Find all income-related variables lookup_variable("income") # Search only variable labels for migration-related items lookup_variable("migrat", fields = "label")
Opens an interactive data explorer with three tabs:
Search and filter variables across all waves by keyword, thematic block, or wave. Click any row to see the full question text and value labels.
Select a wave and variable to view its distribution (bar chart for categorical, histogram for numeric) and summary statistics.
Select a wave and a subset of variables, preview the data, and download as CSV.
run_app(...)run_app(...)
... |
Additional arguments passed to |
Called for its side effect of launching a Shiny app.
if (interactive()) { run_app() }if (interactive()) { run_app() }
A small reference table describing each of the 20 BEMP wave datasets: survey round, mode (in-person / phone), and questionnaire type.
wave_overviewwave_overview
A data frame with 20 rows and 4 columns:
Wave identifier (character), e.g. "w1", "w6_M".
Integer survey round number (1–14).
Survey mode: "in-person" or "phone".
Questionnaire type: "main", "migrant",
"non-migrant", or "village profile".
wave_overview wave_overview[wave_overview$type == "in-person", ]wave_overview wave_overview[wave_overview$type == "in-person", ]