| Title: | Tools to use Economic Policy Institute Microdata Extracts |
|---|---|
| Description: | Tools to download and load the EPI microdata extracts from microdata.epi.org. |
| Authors: | Ben Zipperer [aut, cre], Economic Policy Institute [cph, fnd] |
| Maintainer: | Ben Zipperer <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.11.1 |
| Built: | 2026-05-17 08:54:53 UTC |
| Source: | https://github.com/economic/epiextractr |
Returns file paths for the specified CPS sample and years. Useful for
targets-based workflows where file dependencies need to be tracked.
The result can be passed directly to load_cps() or the load_org(),
load_basic(), etc. wrappers in place of .years.
cps_files( sample, years, extracts_dir = NULL, .quiet = getOption("epiextractr.quiet", FALSE) )cps_files( sample, years, extracts_dir = NULL, .quiet = getOption("epiextractr.quiet", FALSE) )
sample |
CPS sample ("org", "basic", "march", "may") |
years |
years of CPS data (integers) |
extracts_dir |
directory where EPI extracts are |
.quiet |
Logical. Suppress informational messages? Defaults to
|
A character vector of file paths
cps_files("org_sample", 2023:2025) # Pass directly to load functions: load_org_sample(cps_files("org_sample", 2023:2025), year, month, wage) ## Not run: # Use with targets library(tarchetypes) tar_assign({ org_files = cps_files("org", 2020:2025) |> tar_file() org_data = load_org(org_files, year, month, wage) |> tar_target() }) ## End(Not run)cps_files("org_sample", 2023:2025) # Pass directly to load functions: load_org_sample(cps_files("org_sample", 2023:2025), year, month, wage) ## Not run: # Use with targets library(tarchetypes) tar_assign({ org_files = cps_files("org", 2020:2025) |> tar_file() org_data = load_org(org_files, year, month, wage) |> tar_target() }) ## End(Not run)
Retrieve metadata from CPS extract
cps_version(x) cps_citation(x) assert_cps_version(x, version)cps_version(x) cps_citation(x) assert_cps_version(x, version)
x |
EPI CPS extract generated from |
version |
String version number |
cps_version and cps_citation return version or citation strings.
assert_cps_version returns an error when the provided version is incorrect.
cps_org <- load_org_sample(2023:2025) cps_citation(cps_org) cps_version(cps_org)cps_org <- load_org_sample(2023:2025) cps_citation(cps_org) cps_version(cps_org)
Download the EPI CPS extracts to your local machine
download_cps(sample, extracts_dir = NULL, overwrite = FALSE)download_cps(sample, extracts_dir = NULL, overwrite = FALSE)
sample |
CPS sample ("org", "basic", "may") |
extracts_dir |
directory where EPI extracts should be placed |
overwrite |
when TRUE, overwrite data |
downloaded files
## Not run: download_cps(sample = "march", extracts_dir = "/data/cps") ## End(Not run)## Not run: download_cps(sample = "march", extracts_dir = "/data/cps") ## End(Not run)
Select years and variables from the EPI CPS microdata extracts. These data
must first be downloaded using download_cps() or from
https://microdata.epi.org.
load_cps( .sample, .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_basic( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_may( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_org( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_org_sample( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) )load_cps( .sample, .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_basic( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_may( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_org( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) ) load_org_sample( .years, ..., .extracts_dir = NULL, .version_check = TRUE, .quiet = getOption("epiextractr.quiet", FALSE) )
.sample |
CPS sample ("org", "basic", "march", "may") |
.years |
years of CPS data (integers), or file paths from |
... |
tidy selection of variables to keep |
.extracts_dir |
directory where EPI extracts are |
.version_check |
when TRUE, confirm data are same version |
.quiet |
Logical. Suppress informational messages? Defaults to
|
All columns are selected if ... is missing.
.years accepts either integer years or file paths from cps_files().
When file paths are passed, the files are read directly and
.extracts_dir is ignored.
.extracts_dir is required, but if NULL it will look for the environment variables
EPIEXTRACTS_CPSBASIC_DIR EPIEXTRACTS_CPSORG_DIR EPIEXTRACTS_CPSMAY_DIR
which could be set in your .Renviron, for example.
A tibble of CPS microdata
load_cps(): base function group
load_basic(): Load CPS Basic Monthly files
load_may(): Load CPS May files
load_org(): Load CPS ORG files
load_org_sample(): Load a demonstration sample of CPS ORG files; only useful for examples
# Load all columns from the demonstration sample load_org_sample(2023:2024) # Load a selection of columns load_org_sample(2023:2025, year, month, female, wage) # Use cps_files() for targets workflows: org_files = cps_files("org_sample", 2023:2025) load_org_sample(org_files, year, month, wage) ## Not run: # Load real CPS ORG data (requires downloaded extracts): load_org(2010:2019, year, month, orgwgt, female, wage) # This is equivalent to load_cps("org", 2010:2019, year, month, orgwgt, female, wage) ## End(Not run)# Load all columns from the demonstration sample load_org_sample(2023:2024) # Load a selection of columns load_org_sample(2023:2025, year, month, female, wage) # Use cps_files() for targets workflows: org_files = cps_files("org_sample", 2023:2025) load_org_sample(org_files, year, month, wage) ## Not run: # Load real CPS ORG data (requires downloaded extracts): load_org(2010:2019, year, month, orgwgt, female, wage) # This is equivalent to load_cps("org", 2010:2019, year, month, orgwgt, female, wage) ## End(Not run)