Challenge 1 Submission

challenge_1
railroads
faostat
wildbirds
Reading in data and creating a post
Author

Suyash Bhagwat

Published

May 31, 2023

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
#Since this is my first time using R, I am using the easiest data set.
#I am using the read_csv function to read the csv file
data_railroad <- read_csv("_data/railroad_2012_clean_county.csv")

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

Ans: The R code given below contains three common functions (spec(), head() and glimpse()) that are used to describe the data set.

The spec function tells us that the data set has three columns with the datatype given in brackets; state(chr),county(chr) and total_employees(dbl).

Code
#spec function gives an overall idea of the column variable types
spec(data_railroad)
cols(
  state = col_character(),
  county = col_character(),
  total_employees = col_double()
)

The head function gives us the first 6 rows.

Code
#Head function gives the first few rows of the data
head(data_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

The glimpse function gives us the size of the data set which is 2930 rows x 3 cols. It also gives us an idea of the column names and datatypes along with the first few observations. Overall the glimpse function is the most concise method to get information about a data set.

Looking at the data, it looks like it was gathered from the database of a railroad company in 2012 that keeps track of all its employees count by state and county.

Code
glimpse(data_railroad)
Rows: 2,930
Columns: 3
$ state           <chr> "AE", "AK", "AK", "AK", "AK", "AK", "AK", "AL", "AL", …
$ county          <chr> "APO", "ANCHORAGE", "FAIRBANKS NORTH STAR", "JUNEAU", …
$ total_employees <dbl> 2, 7, 2, 3, 2, 1, 88, 102, 143, 1, 25, 154, 13, 29, 45…