Overview

This file is provided as a preliminary resource until this data is added to the critstats package. You may also use this code to gather data related to your class project, thesis, or other academic tasks beyond what is provided below. Content in this file comes from a host of different sources which you should be familiar with prior to access and analyzing any data.

An important first step is to read the codebook for the data. More information can be viewed at the bottom of the file in the references section. This file will be updated periodically.

Set up your work enviornment

Open up a new .Rmd file.

Use {r setup, include=F} in your first code chunk.

knitr::opts_chunk$set(echo = TRUE)

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readr) 
library(dplyr)

To load the National Health Expenditures (NHE) data, you will need to download the .zip file containing the raw data.

The source file for raw data is available here.

Once you have your data, you can then proceed with your cleaning and subsequent analysis.

Load your data

Take note of the directory used here to refer to the folder that is downloaded from the NHE website. All files retain their original download names (and capitalization) to avoid confusion.

# load the data

df <- read_csv("NHE2022/NHE2022.csv")
## New names:
## Rows: 544 Columns: 64
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (64): NATIONAL HEALTH EXPENDITURES BY TYPE OF SERVICE AND SOURCE OF FUND...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...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`
df
## # A tibble: 544 × 64
##    NATIONAL HEALTH EXPEN…¹ ...2  ...3  ...4  ...5  ...6  ...7  ...8  ...9  ...10
##    <chr>                   <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
##  1 Expenditure Amount (Mi… 1960  1961  1962  1963  1964  1965  1966  1967  1968 
##  2 Total National Health … 27,1… 29,0… 31,7… 34,5… 38,2… 41,6… 45,7… 51,1… 58,0…
##  3 Out of pocket           12,7… 13,1… 14,0… 15,1… 16,6… 17,8… 18,1… 17,9… 19,9…
##  4 Health Insurance        7,324 8,043 8,785 9,660 10,7… 11,7… 15,3… 20,7… 24,0…
##  5 Private Health Insuran… 5,639 6,275 6,963 7,720 8,791 9,772 9,980 10,1… 11,4…
##  6 Medicare                -     -     -     -     -     -     1,842 4,924 6,218
##  7 Medicaid (Title XIX)    -     -     -     -     -     -     1,304 3,141 3,541
##  8 Federal                 -     -     -     -     -     -     632   1,525 1,835
##  9 State and Local         -     -     -     -     -     -     672   1,616 1,707
## 10 CHIP (Title XIX and Ti… -     -     -     -     -     -     -     -     -    
## # ℹ 534 more rows
## # ℹ abbreviated name:
## #   ¹​`NATIONAL HEALTH EXPENDITURES BY TYPE OF SERVICE AND SOURCE OF FUNDS:  CALENDAR YEARS 1960 to 2022`
## # ℹ 54 more variables: ...11 <chr>, ...12 <chr>, ...13 <chr>, ...14 <chr>,
## #   ...15 <chr>, ...16 <chr>, ...17 <chr>, ...18 <chr>, ...19 <chr>,
## #   ...20 <chr>, ...21 <chr>, ...22 <chr>, ...23 <chr>, ...24 <chr>,
## #   ...25 <chr>, ...26 <chr>, ...27 <chr>, ...28 <chr>, ...29 <chr>, …

References

Centers for Medicare & Medicaid Services. (n.d.). National health expenditure data: Historical. Retrieved from https://www.cms.gov/data-research/statistics-trends-and-reports/national-health-expenditure-data/historical