
---
title: "Problem Set 03"
author: "WRITE YOUR NAME HERE"
date: "Due Friday, October 7, 2016"
output:
  html_document:
    toc: true
    toc_float: true
    collapsed: false
    smooth_scroll: false
---



## Please Indicate

* Who you collaborated with. If no one, please indicate so: 
* Approximately how much time did you spend on this problem set: 
* What, if anything, gave you the most trouble: 



## Tips

* Knit this file once first to read the questions.
* Remember, pictures are worth a thousand words. Your responses should be a
combination of written analysis/interpretation and graphics.
* You will need to use Google a little to learn some background and for
investigations, as any good data scientist would.
* **I can't emphasize this enough**: Look at and explore your data with the 
`View()` command and
    + play with the Filter button 
    + sort each variable in increasing and decreasing order by clicking the arrow
    next to the variable name
* The above was a mantra on my analyst team at Google: Always stay close to your
data.



```{r, echo=FALSE, message=FALSE}
# Do not modify any code in this block. You need to run it once in your console 
# to load all the necessary packages, but do not change anything.
library(ggplot2)
library(dplyr)
library(Quandl)
library(lubridate)
set.seed(76)
Quandl.api_key("izVwTt9m5VoEe7TsEzdr")
```



## Question 1: Bitcoin and Gold

Imagine you are working for a foreign exchange company. You are presented with a
data set `currencies` (which is loaded in the code block) below, which consists
of data on two forms of tradable currency: bitcoin and gold. Give these pages a read:

* [Bitcoin](https://www.quandl.com/data/BAVERAGE/USD)
* [Gold](https://www.quandl.com/data/BUNDESBANK/BBK01_WT5511)

```{r, cache=TRUE, echo=FALSE}
# Do not modify any code in this block. You need to run it once in your console 
# to load all the necessary data sets, but do not change anything:

# Get bitcoin data off quandl.com
bitcoin <- 
  Quandl("BAVERAGE/USD", start_date="2013-01-01", end_date="2016-01-01") %>% 
  mutate(type="bitcoin", date=ymd(Date)) %>%
  rename(price=`24h Average`) %>% 
  select(type, date, price) 

# Get gold data off quandl.com
gold <- 
  Quandl("BUNDESBANK/BBK01_WT5511", start_date="2013-01-01", end_date="2016-01-01") %>% 
  mutate(type="gold", date=ymd(Date)) %>%
  rename(price=Value) %>% 
  select(type, date, price)

# Combine bitcoin and gold data frames into a single one: currencies
currencies <- bind_rows(bitcoin, gold) %>%
  group_by(type) %>%
  arrange(type, date) %>% 
  mutate(percent_diff = 100*(price-lag(price))/lag(price)) %>% 
  tbl_df()
```

#### a)

Your boss wants to know: "You took Intro to Statistical and Data Sciences right? Give me an
executive summary of trends in these two forms of currency."

```{r}
# Write your code below:

```

#### b)

Your boss wants to know: "So we got an investor who has no stomach for 
volatility in currency prices; they like a nice stable currency to park their
money in and not worry about it. What should they invest in?"

```{r}
# Write your code below:

```

#### c)

Your boss wants to know: "What day did bitcoin lose the most value in one day?
What was a possible cause?"





## Question 2: Cheese and Milk Production

Imagine you are working for the US Department of Agriculture. You want to
compare milk and cheese production in the United States since 1925 using the
following data:

* [Cheese](https://www.quandl.com/data/USDANASS/NASS_CHEESEPRODUCTIONMEASUREDINLB)
* [Milk](https://www.quandl.com/data/NASS_MILKPRODUCTIONMEASUREDINLB)

```{r, cache=TRUE, echo=FALSE}
# Do not modify any code in this block. You need to run it once in your console 
# to load all the necessary data sets, but do not change anything.

# Get cheese data off quandl.com
cheese <- 
  Quandl("USDANASS/NASS_CHEESEPRODUCTIONMEASUREDINLB", start_date="1925-01-01") %>% 
  mutate(type="cheese", date=ymd(Date), value=Value) %>%
  select(type, date, value) 

# Get milk data off quandl.com
milk <- 
  Quandl("USDANASS/NASS_MILKPRODUCTIONMEASUREDINLB", start_date="1925-01-01") %>% 
  mutate(type="milk", date=ymd(Date), value=Value) %>%
  select(type, date, value) 

# Combine cheese and milk into a single one
food <- bind_rows(cheese, milk) %>% 
  tbl_df()
```


#### a)

Between cheese and milk, relatively speaking, which agricultural good has seen 
the bigger overall increases in production?

```{r}
# Write your code below:

```




