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: 776 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.9
## 2 2016-01-05 106. 106. 102. 103. 55791000 97.4
## 3 2016-01-06 101. 102. 99.9 101. 68457400 95.5
## 4 2016-01-07 98.7 100. 96.4 96.4 81094400 91.5
## 5 2016-01-08 98.6 99.1 96.8 97.0 70798000 92.0
## 6 2016-01-11 99.0 99.1 97.3 98.5 49739400 93.5
## 7 2016-01-12 101. 101. 98.8 100.0 49154200 94.8
## 8 2016-01-13 100. 101. 97.3 97.4 62439600 92.4
## 9 2016-01-14 98.0 100. 95.7 99.5 63170100 94.4
## 10 2016-01-15 96.2 97.7 95.4 97.1 79010000 92.1
## # ... with 766 more rows
stocks %>%
ggplot(aes(x = date, y = close)) +
geom_line()
-There are 7 variables
-The variables are date, open, high,low,close,volume,and adjusted
-There are 776 rows
-The row represents the date the data event occurred
stocks <- tq_get("MSFT", get = "stock.prices", from = "2016-01-01")
stocks
## # A tibble: 776 x 7
## date open high low close volume adjusted
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2016-01-04 54.3 54.8 53.4 54.8 53778000 51.3
## 2 2016-01-05 54.9 55.4 54.5 55.0 34079700 51.5
## 3 2016-01-06 54.3 54.4 53.6 54.0 39518900 50.6
## 4 2016-01-07 52.7 53.5 52.1 52.2 56564900 48.8
## 5 2016-01-08 52.4 53.3 52.2 52.3 48754000 49.0
## 6 2016-01-11 52.5 52.8 51.5 52.3 36663600 48.9
## 7 2016-01-12 52.8 53.1 52.1 52.8 36095500 49.4
## 8 2016-01-13 53.8 54.1 51.3 51.6 66883600 48.3
## 9 2016-01-14 52 53.4 51.6 53.1 52381900 49.7
## 10 2016-01-15 51.3 52.0 50.3 51.0 71820700 47.7
## # ... with 766 more rows
stocks %>%
ggplot(aes(x = date, y = close)) +
geom_line()
stocks <- tq_get("MSFT", get = "stock.prices", from = "2017-01-01", to = "
2018-12-15")
stocks
## [1] NA
stocks <- tq_get("UNRATE", get = "economic.data", from = "2016-01-01")
stocks
## # A tibble: 37 x 2
## date price
## <date> <dbl>
## 1 2016-01-01 4.9
## 2 2016-02-01 4.9
## 3 2016-03-01 5
## 4 2016-04-01 5
## 5 2016-05-01 4.8
## 6 2016-06-01 4.9
## 7 2016-07-01 4.8
## 8 2016-08-01 4.9
## 9 2016-09-01 5
## 10 2016-10-01 4.9
## # ... with 27 more rows
stocks %>%
ggplot(aes(x = date, y = price)) +
geom_line()
stocks <- tq_get("USD/EUR", get = "exchange.rate", from = "2016-01-01")
stocks
## # A tibble: 180 x 2
## date exchange.rate
## <date> <dbl>
## 1 2018-08-09 0.864
## 2 2018-08-10 0.873
## 3 2018-08-11 0.876
## 4 2018-08-12 0.877
## 5 2018-08-13 0.878
## 6 2018-08-14 0.879
## 7 2018-08-15 0.882
## 8 2018-08-16 0.879
## 9 2018-08-17 0.877
## 10 2018-08-18 0.874
## # ... with 170 more rows
stocks %>%
ggplot(aes(x = date, y = exchange.rate)) +
geom_line()