Using the given code, answer the questions below.

library(tidyquant) 
library(tidyverse) 

stocks <- tq_get("AAPL", get = "stock.prices", from = "2016-01-01")
stocks
## # A tibble: 784 x 7
##    date        open  high   low close   volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 2016-01-04 103.  105.  102   105.  67649400     99.5
##  2 2016-01-05 106.  106.  102.  103.  55791000     97.0
##  3 2016-01-06 101.  102.   99.9 101.  68457400     95.1
##  4 2016-01-07  98.7 100.   96.4  96.4 81094400     91.1
##  5 2016-01-08  98.6  99.1  96.8  97.0 70798000     91.6
##  6 2016-01-11  99.0  99.1  97.3  98.5 49739400     93.1
##  7 2016-01-12 101.  101.   98.8 100.0 49154200     94.4
##  8 2016-01-13 100.  101.   97.3  97.4 62439600     92.0
##  9 2016-01-14  98.0 100.   95.7  99.5 63170100     94.0
## 10 2016-01-15  96.2  97.7  95.4  97.1 79010000     91.7
## # ... with 774 more rows

Q1. How many columns (variables) are there?

There are seven variables in the table.

Q2. What are the variables?

The variables are: date, open, high, low, close, volume, adjusted

Q3. What does the row represent?

Each row represents a new day that the stock was traded, and the stock prices for that day.

Q4. Download Facebook, in addition to Apple.


stocks_2 <- tq_get(c("FB", "AAPL"),
get = "stock.prices",
from = "2016-01-01")
stocks_2
## # A tibble: 1,568 x 8
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 FB     2016-01-04 102.  102.   99.8 102.  37912400    102. 
##  2 FB     2016-01-05 103.  104.  102.  103.  23258200    103. 
##  3 FB     2016-01-06 101.  104.  101.  103.  25096200    103. 
##  4 FB     2016-01-07 100.  101.   97.3  97.9 45172900     97.9
##  5 FB     2016-01-08  99.9 100.   97.0  97.3 35402300     97.3
##  6 FB     2016-01-11  97.9  98.6  95.4  97.5 29932400     97.5
##  7 FB     2016-01-12  99   100.0  97.6  99.4 28395400     99.4
##  8 FB     2016-01-13 101.  101.   95.2  95.4 33410600     95.4
##  9 FB     2016-01-14  95.8  98.9  92.4  98.4 48658600     98.4
## 10 FB     2016-01-15  94.0  96.4  93.5  95.0 45935600     95.0
## # ... with 1,558 more rows

Q5. On how many days did Facebook close higher than $200 per share?

filter(stocks_2, symbol == "FB", close > 200)
## # A tibble: 17 x 8
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 FB     2018-06-20  199.  204.  199.  202  28230900     202 
##  2 FB     2018-06-21  203.  203.  200.  202. 19045700     202.
##  3 FB     2018-06-22  201.  202.  199.  202. 17420200     202.
##  4 FB     2018-07-06  198.  204.  198.  203. 19740100     203.
##  5 FB     2018-07-09  205.  206.  202.  205. 18149400     205.
##  6 FB     2018-07-10  204.  205.  202.  204. 13190100     204.
##  7 FB     2018-07-11  202.  204.  202.  203. 12927400     203.
##  8 FB     2018-07-12  203.  207.  203.  207. 15454700     207.
##  9 FB     2018-07-13  208.  208.  206.  207. 11486800     207.
## 10 FB     2018-07-16  208.  209.  207.  207. 11078200     207.
## 11 FB     2018-07-17  205.  210.  205.  210. 15349900     210.
## 12 FB     2018-07-18  210.  211.  208.  209. 15334900     209.
## 13 FB     2018-07-19  209.  210.  208.  208. 11350400     208.
## 14 FB     2018-07-20  209.  212.  208.  210. 16163900     210.
## 15 FB     2018-07-23  211.  212.  209.  211. 16732000     211.
## 16 FB     2018-07-24  215.  216.  213.  215. 28468700     215.
## 17 FB     2018-07-25  216.  219.  214.  218. 58954200     218.

There were 17 days that Facebook closed higher than 200.

Q6. What was the highest closing price of Facebook.

stocks_2 %>%
  filter(symbol == "FB") %>%
  arrange(desc(close))
## # A tibble: 784 x 8
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 FB     2018-07-25  216.  219.  214.  218. 58954200     218.
##  2 FB     2018-07-24  215.  216.  213.  215. 28468700     215.
##  3 FB     2018-07-23  211.  212.  209.  211. 16732000     211.
##  4 FB     2018-07-17  205.  210.  205.  210. 15349900     210.
##  5 FB     2018-07-20  209.  212.  208.  210. 16163900     210.
##  6 FB     2018-07-18  210.  211.  208.  209. 15334900     209.
##  7 FB     2018-07-19  209.  210.  208.  208. 11350400     208.
##  8 FB     2018-07-13  208.  208.  206.  207. 11486800     207.
##  9 FB     2018-07-16  208.  209.  207.  207. 11078200     207.
## 10 FB     2018-07-12  203.  207.  203.  207. 15454700     207.
## # ... with 774 more rows

The highest closing price of the Facebook stock was $218.

Q7. Download exchange rate between the U.S. dollar and the Japanese yen, save the retrieved data under the name, “FX”, instead of “stocks”, and print the data.


FX <- tq_get("JPY/USD", 
                  get = "exchange.rates", 
                  from = Sys.Date() - lubridate::days(10))
FX
## # A tibble: 10 x 2
##    date       exchange.rate
##    <date>             <dbl>
##  1 2019-02-04       0.00910
##  2 2019-02-05       0.00910
##  3 2019-02-06       0.00911
##  4 2019-02-07       0.00910
##  5 2019-02-08       0.00911
##  6 2019-02-09       0.00911
##  7 2019-02-10       0.00911
##  8 2019-02-11       0.00908
##  9 2019-02-12       0.00905
## 10 2019-02-13       0.00903

Q8. Display both the code and the results of the code on the webpage.

Q9. Display the title and your name correctly at the top of the webpage.

Q10. Use the correct slug.