Challenge 1 Solution - Railroads

challenge_1
railroads
faostat
wildbirds
Author

Prachiti Parkar

Published

February 22, 2022

Code
library(tidyverse)

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)

Challenge Overview

Today’s challenge is to

  1. read in a dataset, and

  2. describe the dataset using both words and any supporting information (e.g., tables, etc)

Read in the Data

Read in one (or more) of the following data sets, using the correct R package and command.

  • railroad_2012_clean_county.csv ⭐
  • birds.csv ⭐⭐
  • FAOstat*.csv ⭐⭐
  • wild_bird_data.xlsx ⭐⭐⭐
  • StateCounty2012.xls ⭐⭐⭐⭐

Find the _data folder, located inside the posts folder. Then you can read in the data, using either one of the readr standard tidy read commands, or a specialized package such as readxl.

Code
library(readr)
railroad <- read_csv("_data/railroad_2012_clean_county.csv")

 
view(railroad)

# first few rows of the dataset
head(railroad)
# A tibble: 6 × 3
  state county               total_employees
  <chr> <chr>                          <dbl>
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
Code
print("Total number of rows are ")
[1] "Total number of rows are "
Code
nrow(railroad)
[1] 2930

Add any comments or documentation as needed. More challenging data sets may require additional code chunks and documentation.

Describe the data

Using a combination of words and results of R commands, can you provide a high level description of the data? Describe as efficiently as possible where/how the data was (likely) gathered, indicate the cases and variables (both the interpretation and any details you deem useful to the reader to fully understand your chosen data).

The data consists of 3 columns namely, the state, county and the count of the total employees working in a particular county of a particular state and 2930 rows. The data must have been likely gathered by cumulating information from all county of all states.

Code
dim(railroad)
[1] 2930    3
Code
# Identifying the column names of the dataset 
colnames(railroad)
[1] "state"           "county"          "total_employees"
Code
#Filter state AE from the dataset 
filter(railroad, state == "AE")
# A tibble: 1 × 3
  state county total_employees
  <chr> <chr>            <dbl>
1 AE    APO                  2
Code
#Filter the rows that has total_employees between 10 and 100 inclusive
filter(railroad, `total_employees` >= 10 & `total_employees` <= 100)
# A tibble: 1,484 × 3
   state county               total_employees
   <chr> <chr>                          <dbl>
 1 AK    SKAGWAY MUNICIPALITY              88
 2 AL    BIBB                              25
 3 AL    BULLOCK                           13
 4 AL    BUTLER                            29
 5 AL    CALHOUN                           45
 6 AL    CHAMBERS                          13
 7 AL    CHILTON                           72
 8 AL    CLARKE                            26
 9 AL    CLAY                              10
10 AL    COFFEE                            14
# … with 1,474 more rows