DACSS 601: Data Science Fundamentals - FALL 2022
  • Fall 2022 Posts
  • Contributors
  • DACSS

Challenge 1

  • Course information
    • Overview
    • Instructional Team
    • Course Schedule
  • Weekly materials
    • Fall 2022 posts
    • final posts

On this page

  • Challenge Overview
  • Read in the Data
  • Describe the data

Challenge 1

  • Show All Code
  • Hide All Code

  • View Source
challenge_1
railroads
faostat
wildbirds
Author

Lai Wei

Published

October 25, 2022

Code
library(tidyverse)
library(readxl)
library(stringr)
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.

#Import Data

Code
StateCounty2012 <- read_excel("D:/Umass Amherst/DACSS 601/601_Fall_2022/posts/_data/StateCounty2012.xls", skip = 3) %>% 
  select(STATE,COUNTY,TOTAL) %>% 
  filter(!str_detect(STATE,"Total"))
Error: `path` does not exist: 'D:/Umass Amherst/DACSS 601/601_Fall_2022/posts/_data/StateCounty2012.xls'
Code
StateCounty2012 <- head(StateCounty2012,-2)
Error in head(StateCounty2012, -2): object 'StateCounty2012' not found
Code
View(StateCounty2012)
Error in as.data.frame(x): object 'StateCounty2012' not found

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

#Get the colnames’ name

Code
colnames(StateCounty2012)
Error in is.data.frame(x): object 'StateCounty2012' not found
Code
StateCounty2012 %>% 
  select(STATE) %>% 
  distinct()
Error in select(., STATE): object 'StateCounty2012' not found
Source Code
---
title: "Challenge 1"
author: "Lai Wei"
desription: "Reading in data and creating a post"
date: "10/25/2022"
format:
  html:
    toc: true
    code-fold: true
    code-copy: true
    code-tools: true
categories:
  - challenge_1
  - railroads
  - faostat
  - wildbirds
---

```{r}
#| label: setup
#| warning: false
#| message: false

library(tidyverse)
library(readxl)
library(stringr)
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`.

#Import Data

```{r}
StateCounty2012 <- read_excel("D:/Umass Amherst/DACSS 601/601_Fall_2022/posts/_data/StateCounty2012.xls", skip = 3) %>% 
  select(STATE,COUNTY,TOTAL) %>% 
  filter(!str_detect(STATE,"Total"))
StateCounty2012 <- head(StateCounty2012,-2)
View(StateCounty2012)
```

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

#Get the colnames' name

```{r}
colnames(StateCounty2012)
StateCounty2012 %>% 
  select(STATE) %>% 
  distinct()
  
```