challenge_1
Reading in data and creating a post
Author

Priya MArla

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
#loading the data from posts/_data folder
railroad <- read_csv("_data/railroad_2012_clean_county.csv")
#executed dim to know the dimentions i.e number of rows and columns of the dataset
dim(railroad)
[1] 2930    3
Code
#executed colnames to get the column names in the dataset
colnames(railroad)
[1] "state"           "county"          "total_employees"
Code
#executed head to get the first 5 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

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

Code
#getting the distinct number of states and counties in the dataset
railroad%>%
  select(state)%>%
  n_distinct(.)
[1] 53
Code
railroad%>%
  select(county)%>%
  n_distinct(.)
[1] 1709
Code
#maximum of total employees in the dataset
max_count <- summarise(railroad, max(total_employees))
max_count
# A tibble: 1 × 1
  `max(total_employees)`
                   <dbl>
1                   8207
Code
#minimum of total employees in the dataset
min_count <- summarise(railroad, min(total_employees))
min_count
# A tibble: 1 × 1
  `min(total_employees)`
                   <dbl>
1                      1
Code
#mean of total employees in the dataset
mean_count <- summarise(railroad, mean(total_employees))
mean_count
# A tibble: 1 × 1
  `mean(total_employees)`
                    <dbl>
1                    87.2

By reading the data from “railroad_2012_clean_county.csv” dataset, I can see that this dataset describes the statistics of number of employees working in the different states and counties for the railroad in the year 2012. There are about 2930 rows and 3 columns where each row represents the total number of employees in each state and county. There a total of 53 states and 1709 counties. The maximum number of employee count recorded is 8207 and minimum count is 1. The average of total_employees in the entire dataset is 87.17816.