Use the given code below to answer the questions.
Hint: Insert a new code chunk below and type in the code, using the tq_get() function above. Replace the ticker symbol for Walmart. You may find the ticker symbol for Microsoft from Yahoo Finance.
## # A tibble: 1,025 x 7
## date open high low close volume adjusted
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2016-01-04 60.5 61.5 60.4 61.5 11989200 55.7
## 2 2016-01-05 62.0 63.0 61.8 62.9 13326000 57.1
## 3 2016-01-06 62.5 64.0 62.5 63.5 16564600 57.6
## 4 2016-01-07 63.0 65.2 62.9 65.0 26430000 59.0
## 5 2016-01-08 65.1 65.4 63.4 63.5 17767900 57.6
## 6 2016-01-11 63.8 64.5 63.6 64.2 12653800 58.2
## 7 2016-01-12 64.4 64.7 63.4 63.6 12195900 57.7
## 8 2016-01-13 63.7 63.7 61.8 61.9 13725700 56.2
## 9 2016-01-14 62 63.6 61.8 63.1 12934900 57.2
## 10 2016-01-15 61.5 62.5 61.3 61.9 15174400 56.2
## # … with 1,015 more rows
There are 7 different columns or variables in the data set.
## Observations: 1,025
## Variables: 7
## $ date <date> 2016-01-04, 2016-01-05, 2016-01-06, 2016-01-07, 2016-01-08,…
## $ open <dbl> 60.50, 62.03, 62.48, 62.97, 65.08, 63.76, 64.38, 63.73, 62.0…
## $ high <dbl> 61.49, 63.05, 63.95, 65.23, 65.41, 64.47, 64.73, 63.73, 63.6…
## $ low <dbl> 60.36, 61.85, 62.47, 62.92, 63.41, 63.63, 63.43, 61.83, 61.8…
## $ close <dbl> 61.46, 62.92, 63.55, 65.03, 63.54, 64.22, 63.62, 61.92, 63.0…
## $ volume <dbl> 11989200, 13326000, 16564600, 26430000, 17767900, 12653800, …
## $ adjusted <dbl> 55.74186, 57.06602, 57.63741, 58.97971, 57.62833, 58.24507, …
The second observation is Walmart’s stock prices on January 5th, 2016. They opened with a high of 62.03, had a high of 63.05, a low of 61.85, and closed at 62.92. They had a volume of 13,326,000 and an adjusted price of 57.06.
Hint: Watch the video, “Basic Data Types”, in DataCamp: Introduction to R for Finance: Ch1 The Basics.
The data in this data set is numeric data. The other types of basic data in R are logical and character data.
Hint: Insert a new code chunk below and type in the code, using the ggplot() function above. Revise the code so that it maps adjusted to the y-axis, instead of close.
For more information on the ggplot() function, refer to Ch2 Introduction to ggplot2 in one of our e-textbooks, Data Visualization with R.
Walmart’s stock has performed very well since the start of 2019, it has been on a steady increase until 2020 where they started to decline again.
Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.
Hint: Use eval in the chunk option. Refer to the RMarkdown Reference Guide.