Code
library(tidyverse)
::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE) knitr
Linda Humphrey
February 22, 2023
Today’s challenge is to
The data is about Total railroad employment by state and county
The data contains variables such as,calender year 2012, States, Counties and number of railroad employees in each of the states in accordance to the counties.
Read in one (or more) of the following data sets, using the correct R package and command.
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
.
# A tibble: 2,785 × 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 SKAGWAY MUNICIPALITY 88
7 AL AUTAUGA 102
8 AL BALDWIN 143
9 AL BIBB 25
10 AL BLOUNT 154
# … with 2,775 more rows
# A tibble: 2,930 × 3
state county total_employees
<chr> <chr> <dbl>
1 IL COOK 8207
2 TX TARRANT 4235
3 NE DOUGLAS 3797
4 NY SUFFOLK 3685
5 VA INDEPENDENT CITY 3249
6 FL DUVAL 3073
7 CA SAN BERNARDINO 2888
8 CA LOS ANGELES 2545
9 TX HARRIS 2535
10 NE LINCOLN 2289
# … with 2,920 more rows
Add any comments or documentation as needed. More challenging data sets may require additional code chunks and documentation.
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).
[1] TRUE
[1] 3
[1] 2930
[1] 8207
[1] 1
[1] 87.17816
---
title: "Challenge 1"
author: "Linda Humphrey"
description: "Reading in data and creating a post"
date: "02/22/2023"
format:
html:
toc: true
code-fold: true
code-copy: true
code-tools: true
categories:
- challenge_1: railroad_2012_clean_county.csv
- my name: Linda Humphrey
- dataset: railroad_2012_clean_county.csv
---
```{r}
#| label: setup
#| warning: false
#| message: false
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
The data is about Total railroad employment by state and county
2) describe the dataset using both words and any supporting information (e.g., tables, etc)
The data contains variables such as,calender year 2012, States, Counties and number of railroad employees in each of the states in accordance to the counties.
## 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`.
```{r}
library(readr)
dataset <- read_csv("~/Desktop/Dacss601_spring2023/posts/_data/railroad_2012_clean_county.csv")
View(dataset)
#Filter dataset of total_employees >= 2
filter(dataset, total_employees >= 2)
```
```{r}
#Arrange dataset of state & total_employees
dataset <- read_csv("~/Desktop/Dacss601_spring2023/posts/_data/railroad_2012_clean_county.csv")
arrange(dataset, desc(total_employees))
```
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).
```{r}
#| label: summary provides dataset of railroad total employess by state & county
dataset <- read_csv("~/Desktop/Dacss601_spring2023/posts/_data/railroad_2012_clean_county.csv")
dataset <- read_csv("~/Desktop/Dacss601_spring2023/posts/_data/railroad_2012_clean_county.csv")
print(is.data.frame(dataset))
print(ncol(dataset))
print(nrow(dataset))
# Get the max total_employees from dataset
total_employees <- max(dataset$total_employees)
print(total_employees)
# Get details of state with min total_employees from dataset
dataset <- read_csv("~/Desktop/Dacss601_spring2023/posts/_data/railroad_2012_clean_county.csv")
total_employees <- min(dataset$total_employees)
print(total_employees)
# Get details of state with Mean total_employees from dataset
dataset <- read_csv("~/Desktop/Dacss601_spring2023/posts/_data/railroad_2012_clean_county.csv")
total_employees.mean <- mean(dataset$total_employees)
print(total_employees.mean)
```