Reading in .xls data & doing a bit of tidying!
type -> character string Represents the state that railroad employees worked.
type -> character string Represents the county within the corresponding state.
type -> dbl Number of employees working for the railroad in the corresponding state and county.
The original dataset has been modified to display the results for US railroad employment in Massachusetts.
library(readxl)
StateCounty2012 <- read_excel("HW2/StateCounty2012.xlsx", skip = 2)
state_county <- StateCounty2012[c(1,3,5)]
state_county %>%
rename(state = STATE, county = COUNTY, num_employees = TOTAL) %>%
drop_na(county) %>%
filter(state == "MA") %>%
arrange(desc(num_employees))
# A tibble: 12 × 3
state county num_employees
<chr> <chr> <dbl>
1 MA MIDDLESEX 673
2 MA SUFFOLK 558
3 MA PLYMOUTH 429
4 MA NORFOLK 386
5 MA ESSEX 314
6 MA WORCESTER 310
7 MA BRISTOL 232
8 MA HAMPDEN 202
9 MA FRANKLIN 113
10 MA HAMPSHIRE 68
11 MA BERKSHIRE 50
12 MA BARNSTABLE 44
Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Perry (2022, Feb. 9). Data Analytics and Computational Social Science: Homework 2. Retrieved from https://github.com/DACSS/dacss_course_website/posts/httpsdamionperrygithubiodcss601posts/
BibTeX citation
@misc{perry2022homework, author = {Perry, Damion}, title = {Data Analytics and Computational Social Science: Homework 2}, url = {https://github.com/DACSS/dacss_course_website/posts/httpsdamionperrygithubiodcss601posts/}, year = {2022} }