Registered Nurses in the United States and Territories
Understanding wages for Registered Nurses.
tidytuesday
Author
Ted Laderas
Published
October 5, 2021
Research Question(s)
Which states have the highest overall wages for registered nurses? When did this happen?
Have wages increased overall for registered nurses across all states?
Loading Data
We’ll use the Tidy Tuesday code to directly load the data from the GitHub repository. We’ll also pass it into janitor::clean_names() to standardize the column names. (Life is too short to have to worry about whitespace and capitalization.)
Rows: 1242 Columns: 22
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): State
dbl (21): Year, Total Employed RN, Employed Standard Error (%), Hourly Wage ...
ℹ 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.
Initial EDA
We can see there are 22 columns overall. 21 of these are numeric.
Let’s visualize whether hourly wages are increasing or decreasing across the dataset by making a heatmap. On the x-axis, we will visualize year, and we will visualize by state on our y-axis. We’re going to map the fill value to hourly_wage_median:
Looking for trends in the nurses data, let’s try and scale each income so we can emphasize whether there were increases or decreases within each state. We’re just looking for trends here and whether the slope of these trends is the same for each state.
Note that by scaling within a state (transforming each value to a z-score), we are losing information, but we can see whether wages are steadily increasing for each of the states/territories.
In general, with some exceptions (Guam and Virgin Islands), most registered nurses saw an increase in median hourly wages from 1998 to 2020.
Since we looked at median hourly income, the question is whether these trends are the same or different for the 10th and 90th percentiles of registered nurses.
For the most part, if you are in the 90th percentile of hourly wages, you have seen a leveling off of income after about 2008. After 2008, the 90th income seems pretty static and unchanging.
nurses %>%mutate(state=forcats::fct_rev(state)) %>%group_by(state) %>%mutate(scaled_income =scale(hourly_90th_percentile)) %>%ggplot() +aes(x=year, y=state, fill=scaled_income) +geom_tile(color="grey10") +scale_fill_distiller() + bplots::theme_avenir() +ggtitle("90 percentile RNs have slower increases in income than the 10%")
Making heatmaps with dendrograms
Pivoting the data to be wider
One question we might ask are whether there are groupings by states in terms of the wage increases.
We can do this by pivoting the data and using the {heatmaply} package to make a matrix input suitable for heatmaply::heatmaply().
Here, we take hourly_wage_median and use it in the values of our matrix. Our rows correspond to state and our columns correspond to year.
We can now ask questions about the actual income values. We make heatmaply only look at computing a dendrogram for the rows (states) to look for clustering patterns.
Note we have to set our scale argument to none here.
heatmaply(nurse_median_matrix, dendrogram ="row", Colv =c(1:23), scale="none",main ="Oregon, California, and Hawaii have the highest median wage from 2017-2020")
Scaling by state
If we are interested in relative (scaled) values, the dendrogram is a little less interesting. Overall you can see that all states showed an increase in hourly median wage over the years.
heatmaply(nurse_median_matrix, dendrogram ="row", Colv =c(1:23), scale="row", main="Upward trends overall in terms of hourly median wage")
Conclusions
This was a nice dataset to get back into Tidy Tuesday.
Median wages have increased across all states for Registered Nurses.
Hawaii, Oregon, and California have the highest overall wages for Registered Nurses
Citation
BibTeX citation:
@online{laderas2021,
author = {Laderas, Ted and Laderas, Ted},
title = {Registered {Nurses} in the {United} {States} and
{Territories}},
date = {2021-10-05},
url = {https://laderast.github.io//articles/2021-10-05-registered-nurses/2021-10-05-registered-nurses.html},
langid = {en}
}