Code
library(tidyverse)
::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE) knitr
Will Munson
August 18, 2022
Today’s challenge is to:
Read in one (or more) of the following datasets, using the correct R package and command.
Is your data already tidy, or is there work to be done? Be sure to anticipate your end result to provide a sanity check, and document your work here.
Any additional comments?
I believe the data is already tidy. Each value has its own column, and there's not much to do. However, I noticed that the year column seems to be backwards, and the price values don't round up to two digits. I'm not sure if that's a problem.
Are there any variables that require mutation to be usable in your analysis stream? For example, are all time variables correctly coded as dates? Are all string variables reduced and cleaned to sensible categories? Do you need to turn any variables into factors and reorder for ease of graphics and visualization?
Document your work here.
# A tibble: 600 × 4
Product Year Month Price_Dollar
<chr> <dbl> <chr> <dbl>
1 B/S Breast 2004 January 6.46
2 B/S Breast 2004 February 6.42
3 B/S Breast 2004 March 6.42
4 B/S Breast 2004 April 6.42
5 B/S Breast 2004 May 6.42
6 B/S Breast 2004 June 6.41
7 B/S Breast 2004 July 6.42
8 B/S Breast 2004 August 6.42
9 B/S Breast 2004 September 6.42
10 B/S Breast 2004 October 6.42
# … with 590 more rows
# ℹ Use `print(n = ...)` to see more rows
Any additional comments?
While the data might be tidy, you should also check and make sure the values are entered in a way that makes sense. Otherwise, there's
---
title: "Challenge 4 Will Munson"
author: "Will Munson"
desription: "More data wrangling: pivoting"
date: "08/18/2022"
format:
html:
toc: true
code-fold: true
code-copy: true
code-tools: true
categories:
- challenge_4
---
```{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) tidy data (as needed, including sanity checks)
3) identify variables that need to be mutated
4) mutate variables and sanity check all mutations
## Read in data
Read in one (or more) of the following datasets, using the correct R package and command.
- abc_poll.csv ⭐
- poultry_tidy.csv⭐⭐
- FedFundsRate.csv⭐⭐⭐
- hotel_bookings.csv⭐⭐⭐⭐
- debt_in_trillions ⭐⭐⭐⭐⭐
```{r}
poultry_tidy<-read_csv("_data/poultry_tidy.csv",
show_col_types = FALSE)
```
### Briefly describe the data
## Tidy Data (as needed)
Is your data already tidy, or is there work to be done? Be sure to anticipate your end result to provide a sanity check, and document your work here.
```{r}
```
Any additional comments?
I believe the data is already tidy. Each value has its own column, and there's not much to do. However, I noticed that the year column seems to be backwards, and the price values don't round up to two digits. I'm not sure if that's a problem.
## Identify variables that need to be mutated
Are there any variables that require mutation to be usable in your analysis stream? For example, are all time variables correctly coded as dates? Are all string variables reduced and cleaned to sensible categories? Do you need to turn any variables into factors and reorder for ease of graphics and visualization?
Document your work here.
```{r}
poultry_tidy %>%
arrange(Product, Year) %>%
mutate_at(vars(Price_Dollar), funs(round(., digit = 2)))
```
Any additional comments?
While the data might be tidy, you should also check and make sure the values are entered in a way that makes sense. Otherwise, there's