-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
69 lines (43 loc) · 2.26 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
69
---
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%"
)
```
# leaidr <img src='man/figures/logo.png' align="right" height="150" />
<!-- badges: start -->
<!-- badges: end -->
The goal of leaidr is to provide an easy way to map U.S. school districts in R.
## Installation
You can install the development version of this package from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("ivelasq/leaidr")
```
## About
School districts in the U.S. have associated local education agency identification numbers (LEAID) used in the [National Center for Education Statistics (NCES)](https://nces.ed.gov/) Common Core of Data. These are very useful because if you have other datasets with NCES ID’s, then you can (sometimes easily) join them.
The original shapefiles can be found on the [NCES](https://nces.ed.gov/programs/edge/Geographic/DistrictBoundaries) site. These files are from 2019. All the state-level shapefiles are saved [here](https://github.com/datalorax/us-district-shapefiles/tree/master/individ-districts).
## Get the U.S. Shapefile
Load the shapefile for the entire U.S. using `lea_get()` and the state abbreviation. Loading may take a while. You will have to load the shapefile anytime you're in a new directory/project.
If you use `lea_get()` (i.e., with `state = NULL`), you get all the district shapefiles for the whole U.S. via ROpenSci's {piggyback}.
**You must have a GITHUB_PAT before you can run `lea_get()`.** You can set a token in your [developer settings](https://github.com/settings/tokens) and save it in your R Environment. More info can be found in [Happy git with R](https://happygitwithr.com/github-pat.html).
## Use the Data
Once you have the shapefile, you can plot using packages like {leaflet} and {ggplot2}.
### {ggplot2} Example
```{r, message = FALSE, dpi = 300}
library(leaidr)
tn <- lea_get("tn")
tn %>%
sf::st_as_sf() %>%
ggplot2::ggplot() +
ggplot2::geom_sf()
```
### Mapbox example
## Acknowlegements
Many thanks to [datalorax](https://github.com/datalorax) for the incredible improvements to this package.