-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
69 lines (57 loc) · 1.93 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
basic_exists <- file.exists(Sys.getenv("EPIEXTRACTS_CPSBASIC_DIR"))
org_exists <- file.exists(Sys.getenv("EPIEXTRACTS_CPSORG_DIR"))
```
# epiextractr
<!-- badges: start -->
<!-- badges: end -->
epiextractr makes it easy to use the [EPI microdata extracts](https://microdata.epi.org/) in R.
## Example
Load a selection of variables from the 2019-2021 EPI CPS ORG extracts:
```{r, eval = org_exists}
library(epiextractr)
load_org(2019:2021, year, female, wage, orgwgt)
```
```{r, echo = FALSE, eval = !org_exists}
cat("
# A tibble: 824,963 × 4
year orgwgt female wage
<int> <dbl> <int+lbl> <dbl>
1 2019 11367. 1 [Female] 14
2 2019 6541. 1 [Female] 20.9
3 2019 6327. 0 [Male] 7.65
4 2019 6327. 0 [Male] 7.65
5 2019 11262. 1 [Female] 10
6 2019 7867. 1 [Female] 28.8
7 2019 11262. 1 [Female] 11
8 2019 7943. 0 [Male] NA
9 2019 6092. 1 [Female] NA
10 2019 7738. 0 [Male] NA
# … with 824,953 more rows
")
```
## Installation and basic usage
First, install the current version of the package from R-Universe:
```{r, eval = FALSE}
install.packages("epiextractr", repos = c("https://economic.r-universe.dev", "https://cloud.r-project.org"))
```
Then download the CPS microdata using `download_cps()`. For example,
```{r, eval = FALSE}
download_cps("org", "C:\data\cps")
```
will download the latest EPI CPS ORG extracts in .feather format from https://microdata.epi.org and place them in the directory `C:\data\cps`.
After the data is downloaded, load a selection of CPS data for your analysis:
```{r, eval = FALSE}
load_cps("org", 2000:2019, year, orgwgt, wage, wbho, .extracts_dir = "C:\data\cps")
```
See `vignette("epiextractr")` for more examples.