challenge_1
Reading in data and creating a post
Author

Cristhian Barba Garzon

Published

December 26, 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.xlsx ⭐⭐⭐⭐

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
x = read_csv("_data/railroad_2012_clean_county.csv")
view(x)

summary(x)
    state              county          total_employees  
 Length:2930        Length:2930        Min.   :   1.00  
 Class :character   Class :character   1st Qu.:   7.00  
 Mode  :character   Mode  :character   Median :  21.00  
                                       Mean   :  87.18  
                                       3rd Qu.:  65.00  
                                       Max.   :8207.00  
Code
#in the employees column, the summary functions provides the min, max, and mean
#the max number of employees is about 8,207

x%>%
  select(state)%>%
  distinct()
# A tibble: 53 × 1
   state
   <chr>
 1 AE   
 2 AK   
 3 AL   
 4 AP   
 5 AR   
 6 AZ   
 7 CA   
 8 CO   
 9 CT   
10 DC   
# … with 43 more rows
Code
#tells us how many distinct values are in the states column
#there are 53 distinct values 

x%>%
  select(county)%>%
  distinct()
# A tibble: 1,709 × 1
   county              
   <chr>               
 1 APO                 
 2 ANCHORAGE           
 3 FAIRBANKS NORTH STAR
 4 JUNEAU              
 5 MATANUSKA-SUSITNA   
 6 SITKA               
 7 SKAGWAY MUNICIPALITY
 8 AUTAUGA             
 9 BALDWIN             
10 BARBOUR             
# … with 1,699 more rows
Code
#this tells us how many distinct counties were used to record data

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

Data Summary

Using commands in R, I was able to establish that this data was recorded in about 53 states/territoriess in the US. That information was found out by using the select() and distinct() functions, which helped find the unique values in the states column. Additionally, using the same functions, I was able to find out the amount of counties that data was recorded in. The summary() command was used to provide a quick summary of what the data consists of; this function provided information on the maximum, minimum, and mean amount of employees in each state, in each county.