In this exercise you will learn to plot data using the ggplot2 package. To answer the questions below, use 4.1 Categorical vs. Categorical from Data Visualization with R.
Hint: See the code in 4.3.1 Bar chart (on summary statistics).
Hint: See the code in 4.3.1 Bar chart (on summary statistics). ## Q3 Label the bars with mean yearly returns. Hint: See the code in 4.3.1 Bar chart (on summary statistics).
## Q4 Plot the distribution of yearly returns by stock using kernel density plots. Hint: See the code in 4.3.2 Grouped kernel density plots.
## Q5 Which of the three stocks has highest chance of losing big when things go wrong? Discuss your reason. Hint: Google how to interpret density plots.
The company that has the biggest chance of losing big because of its lack of consistency and the fact that they had the best year out of everyone. If they were to lose they would lose it all which is more than everyone else. ## Q6 Plot the distribution of yearly returns by stock using boxplots. Hint: See the code in 4.3.3 Box plots.
## Q7 If you were a risk-loving investor (defined as one chasing after the greatest returns even at the risk of losing big), which of the three stocks would you choose? Discuss your reason. Apple seems to be the very best option for those who want to take risk because of how many outliers it seems to have. On a good year you can get returns of up to 2. ## Q8 Hide the messages, but display the code and their results from the webpage. Hint: Use
message, echo and results in the global chunk options. Refer to the RMarkdown Reference Guide.