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

Challenge 3 Instructions

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

On this page

  • Challenge Overview
  • Read in data
  • Reading Animal Weights
    • Briefly describe the data
  • Anticipate the End Result
  • Pivot the Data

Challenge 3 Instructions

  • Show All Code
  • Hide All Code

  • View Source
challenge_3
animal_weights
Author

Connor Skowyra

Published

October 3, 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 data set, and describe the data set using both words and any supporting information (e.g., tables, etc)
  2. identify what needs to be done to tidy the current data
  3. anticipate the shape of pivoted data
  4. pivot the data into tidy format using pivot_longer

Read in data

Read in one (or more) of the following datasets, using the correct R package and command.

  • animal_weights.csv ⭐
  • eggs_tidy.csv ⭐⭐ or organiceggpoultry.xls ⭐⭐⭐
  • australian_marriage*.xls ⭐⭐⭐
  • USA Households*.xlsx ⭐⭐⭐⭐
  • sce_labor_chart_data_public.xlsx 🌟🌟🌟🌟🌟

Reading Animal Weights

(animal_weight <- read.csv(“posts/_data/animal_weight.csv”))

Briefly describe the data

This chart describes the animal weights from nine geographic locations around the world while factoring in culture and economics.

Anticipate the End Result

As there are nine geographic locations and sixteen different kinds of livestock, we should multiple the 9 locations with the 16 kinds of livestock to get a total amount of observations which equals 144. We will using the column names of IPCC.Area, Farm Animal and Weight Per Animal equaling three columns.

9*16=144

Pivot the Data

Document your work here.

animal_weight_longer<-pivot_longer(animal_weight, col=-IPCC.Area, names_to = “Farm Animal, values_to =”Weight Per Animal”) > animal_weight_longer

Inputting this Pivot allows you to see the weight and kind of farm animal related to each specific region. We will also be able to confirm that the animal_weight_longer has 144 rows and 3 columns confirming the tidying process.

Source Code
---
title: "Challenge 3 Instructions"
author: "Connor Skowyra"
desription: "Tidy Data: Pivoting"
date: "10/3/2022"
format:
  html:
    toc: true
    code-fold: true
    code-copy: true
    code-tools: true
categories:
  - challenge_3
  - animal_weights
---

```{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 data set, and describe the data set using both words and any supporting information (e.g., tables, etc)
2.  identify what needs to be done to tidy the current data
3.  anticipate the shape of pivoted data
4.  pivot the data into tidy format using `pivot_longer`

## Read in data

Read in one (or more) of the following datasets, using the correct R package and command.

-   animal_weights.csv ⭐
-   eggs_tidy.csv ⭐⭐ or organiceggpoultry.xls ⭐⭐⭐
-   australian_marriage\*.xls ⭐⭐⭐
-   USA Households\*.xlsx ⭐⭐⭐⭐
-   sce_labor_chart_data_public.xlsx 🌟🌟🌟🌟🌟

## Reading Animal Weights

(animal_weight <- read.csv("posts/_data/animal_weight.csv"))

### Briefly describe the data

This chart describes the animal weights from nine geographic locations around the world while factoring in culture and economics.

## Anticipate the End Result

As there are nine geographic locations and sixteen different kinds of livestock, we should multiple the 9 locations with the 16 kinds of livestock to get a total amount of observations which equals 144. We will using the column names of IPCC.Area, Farm Animal and Weight Per Animal equaling three columns.

9*16=144

## Pivot the Data

Document your work here.

animal_weight_longer<-pivot_longer(animal_weight, 
col=-`IPCC.Area`,
names_to = "Farm Animal,
values_to = "Weight Per Animal")
> animal_weight_longer

Inputting this Pivot allows you to see the weight and kind of farm animal related to each specific region. We will also be able to confirm that the animal_weight_longer has 144 rows and 3 columns confirming the tidying process.