You are evaluating the performance of two stocks, Microsoft and Apple, for future investment.
Hint: Add group_by(symbol) at the end of the code so that calculations below will be done per stock.
The first row has the symbol of the company, the date, open stock price, high stock price, low stock price, closing stock price, volume and adjusted. In the first row Microsoft opened its stock at 38.9. It reached a high of 39.8 and A LOW OF 38.8. Microsoft closed at 39.8.
Hint: Use ggplot2::facet_wrap. Refer to the ggplot2 cheatsheet. See the section for Faceting.
Hint: Take the adjusted variable from Stocks, and calculate yearly returns using tq_transmute(), instead of tq_mutate(), which is used when periodicity changes. Another difference between the two is that tq_transmute() returns only newly-created columns while tq_mutate() adds new columns to existing variables.
Hint: Refer to the ggplot2 cheatsheet. Look for geom_boxplot under Two Variables. Note that the discrete variable should be mapped to the x-axis and the continuous variable to the y-axis.
Hint: Discuss your answer in terms of the median in the boxplot you created in Q5. Google “Interpreting boxplots in R” to find the information you need.
Apples yearly return will be higher than Microsoft. Apples median in the boxplot is higher than Microsofts median which results in Apple having a higher yearly return.
Hint: Discuss your answer in terms of the interquartile range (the middle 50%) of the boxplot you created in Q5. Apple would be risker than Microsoft because it has a smaller interquartile range. Also, Apple has more whiskers outside the middle 50% compared to Microsoft.
Hint: Change echo and results in the chunk options. The published webpage should display charts.