dividends
Import dividends of Ford Motor Company and General Motors Company since 2015.economic data
Import the U.S. Industrial Production Index since 1920.exchange rates
Import exchange rate between the U.S. dollar and the South Korean Won.stock prices
Import stock price of Apple, Microsoft and Facebook since 2010.filter
Select Apple and Microsoft.Scatterplot
Plot relationships between volume and closing price for Apple, Microsoft and Facebook, using the facet_wrap function. Add the best fit line.dividends
Import dividends of Ford Motor Company and General Motors Company since 2015.## # A tibble: 40 x 3
## symbol date dividends
## <chr> <date> <dbl>
## 1 F 2015-01-28 0.15
## 2 F 2015-04-29 0.15
## 3 F 2015-07-29 0.15
## 4 F 2015-10-28 0.15
## 5 F 2016-01-27 0.4
## 6 F 2016-04-27 0.15
## 7 F 2016-07-26 0.15
## 8 F 2016-10-25 0.15
## 9 F 2017-01-18 0.2
## 10 F 2017-04-18 0.15
## # … with 30 more rows
economic data
Import the U.S. Industrial Production Index since 1920.Hint: Find the symbol in FRED.
## # A tibble: 1,196 x 2
## date price
## <date> <dbl>
## 1 1920-01-01 5.79
## 2 1920-02-01 5.79
## 3 1920-03-01 5.68
## 4 1920-04-01 5.37
## 5 1920-05-01 5.51
## 6 1920-06-01 5.57
## 7 1920-07-01 5.43
## 8 1920-08-01 5.46
## 9 1920-09-01 5.26
## 10 1920-10-01 5.04
## # … with 1,186 more rows
exchange rates
Import exchange rate between the U.S. dollar and the South Korean Won.## Warning: Oanda only provides historical data for the past 180 days. Symbol:
## USD/KRW
## # A tibble: 180 x 2
## date exchange.rate
## <date> <dbl>
## 1 2019-04-13 1134.
## 2 2019-04-14 1134.
## 3 2019-04-15 1134.
## 4 2019-04-16 1136.
## 5 2019-04-17 1134.
## 6 2019-04-18 1137.
## 7 2019-04-19 1136.
## 8 2019-04-20 1136.
## 9 2019-04-21 1136.
## 10 2019-04-22 1141.
## # … with 170 more rows
stock prices
Import stock price of Apple, Microsoft and Facebook since 2010.## Warning: x = 'APPL', get = 'stock.prices': Error in getSymbols.yahoo(Symbols = "APPL", env = <environment>, verbose = FALSE, : Unable to import "APPL".
## APPL download failed after two attempts. Error message:
## HTTP error 404.
## Removing APPL.
## # A tibble: 3,929 x 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 MSFT 2010-01-04 30.6 31.1 30.6 31.0 38409100 24.4
## 2 MSFT 2010-01-05 30.8 31.1 30.6 31.0 49749600 24.5
## 3 MSFT 2010-01-06 30.9 31.1 30.5 30.8 58182400 24.3
## 4 MSFT 2010-01-07 30.6 30.7 30.2 30.5 50559700 24.0
## 5 MSFT 2010-01-08 30.3 30.9 30.2 30.7 51197400 24.2
## 6 MSFT 2010-01-11 30.7 30.8 30.1 30.3 68754700 23.9
## 7 MSFT 2010-01-12 30.2 30.4 29.9 30.1 65912100 23.7
## 8 MSFT 2010-01-13 30.3 30.5 30.0 30.4 51863500 24.0
## 9 MSFT 2010-01-14 30.3 31.1 30.3 31.0 63228100 24.5
## 10 MSFT 2010-01-15 31.1 31.2 30.7 30.9 79913200 24.4
## # … with 3,919 more rows
filter
Select Apple and Microsoft.## # A tibble: 2,264 x 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 MSFT 2010-01-04 30.6 31.1 30.6 31.0 38409100 24.4
## 2 MSFT 2010-01-05 30.8 31.1 30.6 31.0 49749600 24.5
## 3 MSFT 2010-01-06 30.9 31.1 30.5 30.8 58182400 24.3
## 4 MSFT 2010-01-07 30.6 30.7 30.2 30.5 50559700 24.0
## 5 MSFT 2010-01-08 30.3 30.9 30.2 30.7 51197400 24.2
## 6 MSFT 2010-01-11 30.7 30.8 30.1 30.3 68754700 23.9
## 7 MSFT 2010-01-12 30.2 30.4 29.9 30.1 65912100 23.7
## 8 MSFT 2010-01-13 30.3 30.5 30.0 30.4 51863500 24.0
## 9 MSFT 2010-01-14 30.3 31.1 30.3 31.0 63228100 24.5
## 10 MSFT 2010-01-15 31.1 31.2 30.7 30.9 79913200 24.4
## # … with 2,254 more rows
Scatterplot
Plot relationships between volume and closing price for Apple, Microsoft and Facebook, using the facet_wrap function. Add the best fit line.The lower the volume the higher thre closing price. Apple looks like the most senstive because the line of best fit is most horizontal.