In this exercise you will learn to plot data using the ggplot2 package. To answer the questions below, use Chapter 4.3 Categorical vs. Quantitative Data Visualization with R.

Q1 Plot the distribution of daily returns by stock using kernel density plots.

Hint: See the code in 4.3.2 Grouped kernel density plots.

Q2 Plot the distribution of daily returns by stock using boxplots.

Hint: See the code in 4.3.3 Box plots. Use the same title as in the density plot.

Q3 Based on the boxplot above, which of the two stocks would you invest in?

Hint: Discuss your answer based on median, the middle 50%, roughly 99% of the data, and outliers.

I would invest with Microsoft over Apple because Microsoft is more likely to have a higher daily return than Apple on a daily basis.

Q4 Calculate mean daily returns for each stock.

Hint: See the code in 4.3.1 Bar chart (on summary statistics).

Q5 Plot mean daily returns using bar charts.

Hint: See the code in 4.3.1 Bar chart (on summary statistics).

Q6 Add the color (cornflowerblue) to the bar chart.

Hint: See the code in 4.3.1 Bar chart (on summary statistics).

Q7 Label the bars with mean daily returns.

Hint: See the code in 4.3.1 Bar chart (on summary statistics).

Q8 Hide the messages, the code, and its results on the webpage.

Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.