Brinda Murulidhara HW2

Data Wrangling

Brinda Murulidhara
2021-12-29

Read in a dataset

I have used the railroad employee count dataset (Filename: railroad_2012_clean_county_tidy.csv) for data wrangling operations. Below is the code snippet to read and preview the data.

railroad_data <- read.csv("railroad_2012_clean_county_tidy.csv")
head(railroad_data)
  state               county total_employees
1    AE                  APO               2
2    AK            ANCHORAGE               7
3    AK FAIRBANKS NORTH STAR               2
4    AK               JUNEAU               3
5    AK    MATANUSKA-SUSITNA               2
6    AK                SITKA               1

Explain the variables in your dataset

Below are the variables in the dataset:

  1. state: The state corresponding to the county under consideration. The data type is String consisting of the abbreviation for the state.
  2. county: The county in which the total number of employees is counted. The data type is String.
  3. total_employees: Total number of railroad employees in a given county. The data type is Numeric

Data-wrangling operations

I filtered rows correspoding to Massachusetts state.

Filter

library("dplyr")
filtered_railroad_data <- filter(railroad_data, state=="MA")

Arrange

I arranged the rows filtered in the previous step by total employee count ascending.

library("dplyr")
arrange(filtered_railroad_data, total_employees)
   state     county total_employees
1     MA BARNSTABLE              44
2     MA  BERKSHIRE              50
3     MA  HAMPSHIRE              68
4     MA   FRANKLIN             113
5     MA    HAMPDEN             202
6     MA    BRISTOL             232
7     MA  WORCESTER             310
8     MA      ESSEX             314
9     MA    NORFOLK             386
10    MA   PLYMOUTH             429
11    MA    SUFFOLK             558
12    MA  MIDDLESEX             673

Reuse

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 ...".

Citation

For attribution, please cite this work as

Murulidhara (2021, Dec. 30). Data Analytics and Computational Social Science: Brinda Murulidhara HW2. Retrieved from https://github.com/DACSS/dacss_course_website/posts/httpsrpubscombrinda851751/

BibTeX citation

@misc{murulidhara2021brinda,
  author = {Murulidhara, Brinda},
  title = {Data Analytics and Computational Social Science: Brinda Murulidhara HW2},
  url = {https://github.com/DACSS/dacss_course_website/posts/httpsrpubscombrinda851751/},
  year = {2021}
}