-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated docs in light of suggestions
- Loading branch information
1 parent
808fbfa
commit 23e6943
Showing
7 changed files
with
132 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Usage | ||
|
||
```{r, include = FALSE, eval=TRUE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
eval = TRUE | ||
) | ||
``` | ||
|
||
`oepsData` is centered around two functions: `load_oeps_dictionary`, which loads a basic data dictionary; and `load_oeps`, which directly loads OEPS data. We expect that most users will start by calling `load_oeps_dictionary` to look at what data is available at their desired analysis scale, followed by calling `load_oeps` to actually load the data. | ||
|
||
## load_oeps_dictionary | ||
|
||
`load_oeps_dictionary` itself takes one argument --- `scale` --- that can be any of "tract", "zcta", "county", or "state". It returns the data dictionary (stored as a data.frame), so we recommend browsing it through the `View` command: | ||
|
||
```{r preview data} | ||
# See what data is available at the state level | ||
data_dictionary <- load_oeps_dictionary(scale="state") | ||
# if working in RStudio, we recommend: | ||
# View(data_dictionary) | ||
# as we're in a bookdown, we just preview it directly: | ||
data_dictionary | ||
``` | ||
|
||
## load_oeps | ||
|
||
We might find that we're interested in the 1990 state data. We can load that data and its geometries using `load_oeps`, which accepts the following arguments: | ||
* `scale` The scale of analysis. One of "tract", "zcta", "county", or "state" | ||
* `year` The release year for the data. One of 1980, 1990, 2000, 2010, or 2018. | ||
* `themes` The theme to pull data for. One of 'Geography", "Social", "Environment", "Economic", "Policy", "Composite", or "All". Defaults `All`. | ||
* `states` A string or vector of strings specifying which states to pull data for, either as FIPS codes or names. Ignored when scale is in ZCTA. Defaults `None`. | ||
* `counties` A string or vector of strings specifying which counties to pull data for, either as FIPS or names. Ignored for ZCTA, and must be specified alongside `states. Defaults `None`. | ||
* `tidy` Boolean specifying whether to return data in tidy format; defaults to `FALSE`. | ||
* `geometry` Boolean specifying whether to pull geometires for the dataset. Defaults `FALSE` | ||
* `cache` Boolean specifying whether to use cahced geometries or not. See the section on [cacheing](https://oepsdata.healthyregions.org/getting-started#cacheing) for more. Defaults `TRUE`. | ||
|
||
```{r basic data loading} | ||
states_1990 <- load_oeps(scale="state", | ||
year=1990, | ||
geometry=TRUE) | ||
head(data.frame(states_1990)) | ||
``` | ||
|
||
Which lets us operate on the data as we desire. For instance, we can make a simple map: | ||
|
||
```{r} | ||
library(tmap) | ||
library(sf) | ||
# reproject to a better display CRS | ||
states_1990 <- st_transform(states_1990, "ESRI:102004") | ||
tm_shape(states_1990) + | ||
tm_fill("NoHsP", style="jenks") + | ||
tm_borders(alpha=0.05) + | ||
tm_layout(main.title = "Population over 25 without a high school degree") | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters