Data Used
My second data set was from the discussion thread ‘BLS earnings table’ by Ambra Barboni-Alexander. ‘tidyr’ and ‘dplyr’ were the main methods to manipulate data. This data looks at ‘Average Hourly and Weekly Earnings of all Employees on Private nonfarm Payrolls by industry sector, seasonally adjusted.’
Reading in Data
This data was read in using htmltab
format.
// Reading in Data
library(tidyr)
library(dplyr)
library(stringr)
library(knitr)
library(htmltab)
URL <- "https://www.bls.gov/news.release/empsit.t19.htm"
Project6DS3 <- htmltab(doc = URL, which = "//th[text() = 'Industry']/ancestor::table")
head(Project6DS3)
kable(head(Project6DS3), caption = "Table 1. Unitdy Data")
The following begins to cleanup process.
// Cleaning Data
Project6DS2<-tbl_df(Project6DS2)
Project6DS2a <- Project6DS2 %>% gather("RegionMetrics","Values",3:5)
Project6DS2a <- Project6DS2a[2:4]
Project6DS2a <- Project6DS2a %>% group_by(CensusRegion, RegionMetrics) %>% spread(CensusRegion, Values)
colnames(Project6DS2a) <- str_to_title(colnames(Project6DS2a))
kable(head(Project6DS2a), caption="Table 2. Data Cleaned Up and Inverted for Analysis")
Industry | Metric | Dec.2016 | Feb.2016 | Feb.2017(P) | Jan.2017(P) |
---|---|---|---|---|---|
Construction | Average hourly earnings | 28.40 | 27.74 | 28.48 | 28.49 |
Construction | Average weekly earnings | 1104.76 | 1087.41 | 1113.57 | 1108.26 |
Durable goods | Average hourly earnings | 27.60 | 26.96 | 27.61 | 27.60 |
Durable goods | Average weekly earnings | 1137.12 | 1110.75 | 1140.29 | 1137.12 |
Education and health services | Average hourly earnings | 26.02 | 25.56 | 26.11 | 26.04 |
Education and health services | Average weekly earnings | 856.06 | 838.37 | 859.02 | 856.72 |
Analyze Data
The original question from the post was ‘Average earnings comparison across industries is the first piece of analysis that could be conducted’ this is being interpreted as Compare the Average Earnings across all industries. I will index each average earning (hourly, weekly) into separate table to index over each period based upon the average to see how each one compares.
#normalizing function built for each column
normalit<-function(m){
(m - min(m))/(max(m)-min(m))
}
Project6DS3b <- Project6DS3a %>% group_by(Metric) %>% mutate(`Feb.2017(P)` = normalit(`Feb.2017(P)`), `Jan.2017(P)` = normalit(`Jan.2017(P)`), `Dec.2016` = normalit(`Dec.2016`), `Feb.2016` = normalit(`Feb.2016`))
#Method 1
kable(Project6DS3b, caption="Table 3. Normalized Average Earnings by Industry")
#subset each metric, average hourly and average weekly.
AvgHourly <- subset(Project6DS3b, Metric=="Average hourly earnings")
AvgWeekly <- subset(Project6DS3b, Metric=="Average weekly earnings")
par(mfrow=c(1,2))
boxplot(AvgHourly[,c(3:6)],main="Boxplot of Average Hourly", ylab="Normalized Earnings for All Industries", xlab="Periods")
boxplot(AvgWeekly[,c(3:6)],main="Boxplot of Average Weekly", ylab="Normalized Earnings for All Industries", xlab="Periods")
Industry | Metric | Dec.2016 | Feb.2016 | Feb.2017(P) | Jan.2017(P) |
---|---|---|---|---|---|
Construction | Average hourly earnings | 0.5627119 | 0.5679066 | 0.5695876 | 0.5585888 |
Construction | Average weekly earnings | 0.5681847 | 0.5937276 | 0.5882974 | 0.5649791 |
Durable goods | Average hourly earnings | 0.5288136 | 0.5341696 | 0.5322165 | 0.5212096 |
Durable goods | Average weekly earnings | 0.5940215 | 0.6133941 | 0.6101488 | 0.5878374 |
Education and health services | Average hourly earnings | 0.4618644 | 0.4736159 | 0.4677835 | 0.4556909 |
Education and health services | Average weekly earnings | 0.3696187 | 0.3838843 | 0.3801276 | 0.3657490 |
As can be seen from the data, Utilities is the most lucrative sector while leisure and hospitality are not. The weekly wages show that on average that most industries center around 0.57 while for the hourly wages most center around 0.47. In theory these values should be identical, however, it appears that for the weekly calculation, more hours were worked in various sectors which would push the normalized tendency up from 0.47 to 0.57.
Appendix
Industry | Metric | Dec.2016 | Feb.2016 | Feb.2017(P) | Jan.2017(P) |
---|---|---|---|---|---|
Construction | Average hourly earnings | 0.5627119 | 0.5679066 | 0.5695876 | 0.5585888 |
Construction | Average weekly earnings | 0.5681847 | 0.5937276 | 0.5882974 | 0.5649791 |
Durable goods | Average hourly earnings | 0.5288136 | 0.5341696 | 0.5322165 | 0.5212096 |
Durable goods | Average weekly earnings | 0.5940215 | 0.6133941 | 0.6101488 | 0.5878374 |
Education and health services | Average hourly earnings | 0.4618644 | 0.4736159 | 0.4677835 | 0.4556909 |
Education and health services | Average weekly earnings | 0.3696187 | 0.3838843 | 0.3801276 | 0.3657490 |
Financial activities | Average hourly earnings | 0.7453390 | 0.7525952 | 0.7538660 | 0.7320454 |
Financial activities | Average weekly earnings | 0.6628689 | 0.6943099 | 0.6799149 | 0.6508918 |
Goods-producing | Average hourly earnings | 0.5135593 | 0.5160035 | 0.5189003 | 0.5086098 |
Goods-producing | Average weekly earnings | 0.5604321 | 0.5786870 | 0.5773553 | 0.5564250 |
Information | Average hourly earnings | 0.9461864 | 0.9333910 | 0.9596220 | 0.9357413 |
Information | Average weekly earnings | 0.7655452 | 0.7752509 | 0.7926317 | 0.7674645 |
Leisure and hospitality | Average hourly earnings | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 |
Leisure and hospitality | Average weekly earnings | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 |
Manufacturing | Average hourly earnings | 0.4750000 | 0.4762111 | 0.4785223 | 0.4687106 |
Manufacturing | Average weekly earnings | 0.5417332 | 0.5560798 | 0.5571557 | 0.5386992 |
Mining and logging | Average hourly earnings | 0.7355932 | 0.7365917 | 0.7478522 | 0.7433851 |
Mining and logging | Average weekly earnings | 0.8193823 | 0.8265152 | 0.8544161 | 0.8255845 |
Nondurable goods | Average hourly earnings | 0.3817797 | 0.3754325 | 0.3857388 | 0.3792524 |
Nondurable goods | Average weekly earnings | 0.4548336 | 0.4604774 | 0.4692509 | 0.4545210 |
Other services | Average hourly earnings | 0.3504237 | 0.3555363 | 0.3603952 | 0.3511130 |
Other services | Average weekly earnings | 0.2818568 | 0.2911214 | 0.2935558 | 0.2803431 |
Private service-providing | Average hourly earnings | 0.4474576 | 0.4537197 | 0.4548969 | 0.4426711 |
Private service-providing | Average weekly earnings | 0.3688841 | 0.3817440 | 0.3783857 | 0.3637847 |
Professional and business services | Average hourly earnings | 0.6826271 | 0.6877163 | 0.6920103 | 0.6745065 |
Professional and business services | Average weekly earnings | 0.5837698 | 0.6055241 | 0.6000000 | 0.5807170 |
Retail trade | Average hourly earnings | 0.1207627 | 0.1362457 | 0.1224227 | 0.1196976 |
Retail trade | Average weekly earnings | 0.1323374 | 0.1443642 | 0.1327772 | 0.1287068 |
Total private | Average hourly earnings | 0.4601695 | 0.4658304 | 0.4669244 | 0.4552709 |
Total private | Average weekly earnings | 0.3996790 | 0.4152630 | 0.4115963 | 0.3964089 |
Trade, transportation, and utilities | Average hourly earnings | 0.3144068 | 0.3239619 | 0.3200172 | 0.3120538 |
Trade, transportation, and utilities | Average weekly earnings | 0.3052025 | 0.3199134 | 0.3116699 | 0.3017124 |
Transportation and warehousing | Average hourly earnings | 0.3550847 | 0.3650519 | 0.3595361 | 0.3511130 |
Transportation and warehousing | Average weekly earnings | 0.4141224 | 0.4329915 | 0.4242149 | 0.4090499 |
Utilities | Average hourly earnings | 1.0000000 | 1.0000000 | 1.0000000 | 1.0000000 |
Utilities | Average weekly earnings | 1.0000000 | 1.0000000 | 1.0000000 | 1.0000000 |
Wholesale trade | Average hourly earnings | 0.6266949 | 0.6267301 | 0.6383162 | 0.6207476 |
Wholesale trade | Average weekly earnings | 0.6150837 | 0.6312911 | 0.6345355 | 0.6105769 |