-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
84 lines (63 loc) · 2.21 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-",
message = FALSE,
warning = FALSE,
cache = TRUE
)
```
# About
[![Travis-CI Build Status](https://travis-ci.org/jjchern/ahrf.svg?branch=master)](https://travis-ci.org/jjchern/ahrf)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/jjchern/ahrf?branch=master&svg=true)](https://ci.appveyor.com/project/jjchern/ahrf)
This repo contains R scripts (in the [`data-raw` folder](https://github.com/jjchern/ahrf/tree/master/data-raw)) that download county-level and state-level
[Area Health Resources Files (AHRF)](http://ahrf.hrsa.gov/download.htm). The datasets are stored in the [`data` folder](https://github.com/jjchern/ahrf/tree/master/data).
AHRF is issued annually.
The most recent release is in 2016 (as of July 24, 2017).
For more information on the AHRF files, see [https://datawarehouse.hrsa.gov/topics/ahrf.aspx](https://datawarehouse.hrsa.gov/topics/ahrf.aspx).
# Installation
You can also download the datasets as an R package.
The size of `ahrf_county.rda` is 17.5M, so it might take a while to install and load into memory.
```R
# install.packages("devtools")
devtools::install_github("jjchern/ahrf@v0.0.1")
# To uninstall the package, use:
# remove.packages("ahrf")
```
# Usage
## Load the state file
```{r}
library(tidyverse)
ahrf::ahrf_state
```
## There're 3230 rows and 6921 columns in the county file (wide format)
```{r}
dim(ahrf::ahrf_county)
```
## Variable labels are included
```{r}
library(labelled)
ahrf::ahrf_county %>%
select(F04437, F00002, contains("F08921"), contains("F11984")) %>%
var_label() %>%
enframe() %>%
unnest()
```
## County-level hospital beds in 2013
```{r}
ahrf::ahrf_county %>%
select(county = F04437,
fips = F00002,
beds_2013 = `F08921-13`,
pop_2013 = `F11984-13`) %>%
mutate(beds_2013 = as.integer(beds_2013),
pop_2013 = as.integer(pop_2013),
beds_2013_p10k = beds_2013 / pop_2013 * 10000) -> beds
beds
lapply(beds, summary)
```