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.
Usage
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)
)Arguments
- .sample
CPS sample ("org", "basic", "march", "may")
- .years
years of CPS data (integers), or file paths from
cps_files()- ...
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
getOption("epiextractr.quiet", FALSE).
Details
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
which could be set in your .Renviron, for example.
Functions
load_cps(): base function groupload_basic(): Load CPS Basic Monthly filesload_may(): Load CPS May filesload_org(): Load CPS ORG filesload_org_sample(): Load a demonstration sample of CPS ORG files; only useful for examples
Examples
# Load all columns from the demonstration sample
load_org_sample(2023:2024)
#> ℹ Using Demonstration sample EPI CPS ORG Extracts, Version 2026.7.8
#> # A tibble: 485,818 × 11
#> year month orgwgt statefips wbho female educ wage wageotc emp
#> <int> <int> <dbl> <int+lbl> <int+lbl> <int+lb> <int+l> <dbl> <dbl> <int+l>
#> 1 2023 1 11181. 1 [AL] 2 [Black] 1 [Fema… 2 [Hig… NA NA 0 [NIL…
#> 2 2023 1 6710. 1 [AL] 1 [White] 1 [Fema… 2 [Hig… NA NA 1 [Emp…
#> 3 2023 1 8748. 1 [AL] 1 [White] 0 [Male] 5 [Adv… 40.8 40.8 1 [Emp…
#> 4 2023 1 7266. 1 [AL] 1 [White] 1 [Fema… 4 [Col… NA NA 1 [Emp…
#> 5 2023 1 13205. 1 [AL] 2 [Black] 0 [Male] 2 [Hig… NA NA 0 [NIL…
#> 6 2023 1 10211. 1 [AL] 1 [White] 1 [Fema… 3 [Som… 12 12 1 [Emp…
#> 7 2023 1 7739. 1 [AL] 2 [Black] 1 [Fema… 2 [Hig… 10 10 1 [Emp…
#> 8 2023 1 10079. 1 [AL] 4 [Other] 0 [Male] 2 [Hig… 18 18 1 [Emp…
#> 9 2023 1 9672. 1 [AL] 1 [White] 1 [Fema… 2 [Hig… NA NA 0 [NIL…
#> 10 2023 1 14535. 1 [AL] 2 [Black] 0 [Male] 2 [Hig… 9.23 9.23 1 [Emp…
#> # ℹ 485,808 more rows
#> # ℹ 1 more variable: lfstat <int+lbl>
# Load a selection of columns
load_org_sample(2023:2025, year, month, female, wage)
#> ! Data for year 2025 excludes October
#> ℹ Using Demonstration sample EPI CPS ORG Extracts, Version 2026.7.8
#> # A tibble: 700,029 × 4
#> year month female wage
#> <int> <int> <int+lbl> <dbl>
#> 1 2023 1 1 [Female] NA
#> 2 2023 1 1 [Female] NA
#> 3 2023 1 0 [Male] 40.8
#> 4 2023 1 1 [Female] NA
#> 5 2023 1 0 [Male] NA
#> 6 2023 1 1 [Female] 12
#> 7 2023 1 1 [Female] 10
#> 8 2023 1 0 [Male] 18
#> 9 2023 1 1 [Female] NA
#> 10 2023 1 0 [Male] 9.23
#> # ℹ 700,019 more rows
# Use cps_files() for targets workflows:
org_files = cps_files("org_sample", 2023:2025)
#> ! Data for year 2025 excludes October
load_org_sample(org_files, year, month, wage)
#> ℹ Using Demonstration sample EPI CPS ORG Extracts, Version 2026.7.8
#> # A tibble: 700,029 × 3
#> year month wage
#> <int> <int> <dbl>
#> 1 2023 1 NA
#> 2 2023 1 NA
#> 3 2023 1 40.8
#> 4 2023 1 NA
#> 5 2023 1 NA
#> 6 2023 1 12
#> 7 2023 1 10
#> 8 2023 1 18
#> 9 2023 1 NA
#> 10 2023 1 9.23
#> # ℹ 700,019 more rows
if (FALSE) { # \dontrun{
# 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)
} # }
