-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
187 lines (118 loc) · 5.6 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
output: github_document
---
<!-- badges: start -->
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![Travis build status](https://travis-ci.org/iecastro/tidyVA.svg?branch=master)](https://travis-ci.org/iecastro/tidyVA)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/iecastro/tidyVA?branch=master&svg=true)](https://ci.appveyor.com/project/iecastro/tidyVA)
<!-- badges: end -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
warning = FALSE
)
devtools::load_all()
library(ggplot2)
library(dplyr)
```
# tidyVA <img src='man/figures/logo.png' align="right" height="139" />
The goal of **tidyVA** is to provide [simple features](https://r-spatial.github.io/sf/articles/sf1.html) of Veterans Health Administration geographies. Data included are tidy data frames of VHA spatial data obtained from [data.va.gov](https://www.data.va.gov/dataset/veterans-integrated-services-networks-visn-markets-submarkets-sectors-and-counties). *Please note the site is no longer operational while VA establishes a new open data portal.*
The benefit of simple features in R is that they allow for [tidy spatial analysis](https://edzer.github.io/UseR2017/geostat2018.html#tidyverse-list-columns).
# Installation
You can install **tidyVA** from GitHub with:
```{r remotes, eval=FALSE}
remotes::install_github("iecastro/tidyVA")
```
# Datasets
## VHA Geographies
The following included datasets are sf-tibbles of VHA geographies with a common CRS - EPSG: 4326.
Summarized descriptions from [data.va.gov](https://www.data.va.gov/dataset/veterans-integrated-services-networks-visn-markets-submarkets-sectors-and-counties)
`county`: The county layer is the base geographic unit of the VISN-Market-Submarket-Sector-County hierarchy.
`sector`: A sector is a cluster of geographically adjacent counties within a VA Submarket.
`submarket`: Submarkets reflect a clustering of the enrolled population within a market and are an aggregation of Sectors.
`market`: Each market is built from submarkets and represent an aggregated geographic area having sufficient population and geographic size to benefit from planning healthcare services. Markets cross state borders where necessary to keep the catchment area within the same market
`visn`: VISNs are the upper echelon in the VHA hierarchy. VISN boundaries align with those of their constituent markets and can span across non-contiguous areas.
### Other Data
`states`: Simple features of states and territories of the US (CRS - EPSG: 4326). Used for spatial joins and geometric manipulations.
`VAloc`: Simple features (CRS - EPSG: 4326) of all VA facilities - from all Administrations: Veterans Health Administration, Veterans Benefits Administration, and National Cemetery Administration
## Example
This is a basic example which shows you how to solve a common problem:
VHA Submarkets are an aggregation of Sectors; and Sectors are comprised of one or more counties. Since each VISN is defined in a hierarchy, this dataset contains attributes of all echelons above submarket - that is, Market and VISN.
```{r example}
library(ggplot2)
library(dplyr)
library(tidyVA)
data("submarket")
```
```{r plot1, eval=FALSE}
ggplot() +
geom_sf(data = submarket, fill = NA)
```
```{r img1, echo=FALSE}
knitr::include_graphics("man/figures/README-example-1.png")
```
Although accurate, this output is not very easy to work with. Since this is in tidy format, though, we can easily filter and manipulate the data.
```{r glimpse}
glimpse(submarket)
```
```{r visn2, eval=FALSE}
visn2 <- submarket %>%
filter(VISN == "02")
visn2
```
```{r visntibble, echo=FALSE}
submarket %>%
filter(VISN == "02")
```
```{r plot2, eval=FALSE}
ggplot() +
geom_sf(data = visn2,
aes(fill = MARKET),
color = NA) +
geom_sf(data = visn2,
fill = NA,
color = "#ffffff",
size = .25)
```
```{r img2, echo=FALSE}
knitr::include_graphics("man/figures/README-unnamed-chunk-4-1.png")
```
# Some Functions
### `shift_geo`
`shift_geo()` will project and re-position Alaska and Hawaii, When supplied a complete dataset (from VHA Geographies).
```{r plot3, eval=FALSE}
shift_geo(submarket) %>%
ggplot() +
geom_sf(fill = NA) +
theme_minimal()
```
```{r img3, echo=FALSE}
knitr::include_graphics("man/figures/README-unnamed-chunk-5-1.png")
```
### `theme_va()`
`theme_va()` is a copy of `theme_ipsum` from [hrbrthemes](https://hrbrmstr.github.io/hrbrthemes/). It's a ggplot theme with some color and plotting modifications to the defaults.
```{r plot4, , eval=FALSE}
data("visn")
visn %>%
ggplot(aes(reorder(VISN,Shape_Area), Shape_Area)) +
geom_col() +
labs(x = "VISN", y = "Shape Area",
caption = "Caption here") +
ggtitle("Shape Area of VA Service Networks",
subtitle = "This is an example plot") +
theme_va(grid = "Y")
```
```{r img4, echo=FALSE}
knitr::include_graphics("man/figures/README-plot4-1.png")
```
### `sail_tidy`
`sail_tidy` will return a tibble of VA SAIL metrics when provided a [data table url](https://www.va.gov/QUALITYOFCARE/measure-up/Strategic_Analytics_for_Improvement_and_Learning_SAIL.asp).
```{r sail}
sail_tidy("https://www.va.gov/QUALITYOFCARE/SAIL_FY19_Q1/SAIL-5_clarksburg_fy19q1.xlsx")
```
# Info
Development of this package partly supported by a research grant from the National Institute on Alcohol Abuse and Alcoholism - NIH Grant #R34AA026745-01.
This product is not endorsed nor certified by either VA or NIH/NIAAA.