challenge_1
railroads
Author

Lindsay Jones

Published

August 15, 2022

Code
library(tidyverse)

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
Code
library(readr)
Railroad <- read_csv("_data/railroad_2012_clean_county.csv")
Railroad

Describe the data

Data set contains the number of railroad employees in the United States in 2012, organized by county. Data was likely gathered reported to labor bureau either by counties or by each railroad station. Each row represents a county. Columns indicate state (or territory), county, and number of employees. There are 2930 counties as shown below:

Code
dim(Railroad)
[1] 2930    3

The 10 counties with the most railroad employees are:

Code
Railroad %>%
  arrange(desc(total_employees)) %>%
  select(state,county,total_employees)%>%
  group_by(total_employees) %>%
  slice(1)%>%
  ungroup()%>%
  arrange(desc(total_employees))%>%
  slice(1:10)

State_Railroad_Props illustrates the percentage of railroad workers located in each state or territory.

Code
State <- select(Railroad, state)
State_Railroad_Props <- prop.table(table(State))*100
State_Railroad_Props
state
        AE         AK         AL         AP         AR         AZ         CA 
0.03412969 0.20477816 2.28668942 0.03412969 2.45733788 0.51194539 1.87713311 
        CO         CT         DC         DE         FL         GA         HI 
1.94539249 0.27303754 0.03412969 0.10238908 2.28668942 5.18771331 0.10238908 
        IA         ID         IL         IN         KS         KY         LA 
3.37883959 1.22866894 3.51535836 3.13993174 3.24232082 4.06143345 2.15017065 
        MA         MD         ME         MI         MN         MO         MS 
0.40955631 0.81911263 0.54607509 2.66211604 2.93515358 3.92491468 2.66211604 
        MT         NC         ND         NE         NH         NJ         NM 
1.80887372 3.20819113 1.67235495 3.03754266 0.34129693 0.71672355 0.98976109 
        NV         NY         OH         OK         OR         PA         RI 
0.40955631 2.08191126 3.00341297 2.49146758 1.12627986 2.21843003 0.17064846 
        SC         SD         TN         TX         UT         VA         VT 
1.56996587 1.77474403 3.10580205 7.54266212 0.85324232 3.13993174 0.47781570 
        WA         WI         WV         WY 
1.33105802 2.35494881 1.80887372 0.75085324