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.

## # A tibble: 80 x 9
## # Groups:   symbol [2]
##    symbol date        open  high   low close   volume adjusted daily.returns
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>         <dbl>
##  1 AAPL   2020-01-02  296.  301.  295.  300. 33870100     300.       0      
##  2 AAPL   2020-01-03  297.  301.  296.  297. 36580700     297.      -0.00972
##  3 AAPL   2020-01-06  294.  300.  293.  300. 29596800     299.       0.00797
##  4 AAPL   2020-01-07  300.  301.  297.  298. 27218000     298.      -0.00470
##  5 AAPL   2020-01-08  297.  304.  297.  303. 33019800     302.       0.0161 
##  6 AAPL   2020-01-09  307.  310.  306.  310. 42527100     309.       0.0212 
##  7 AAPL   2020-01-10  311.  313.  308.  310. 35161200     310.       0.00226
##  8 AAPL   2020-01-13  312.  317.  311.  317. 30383000     316.       0.0214 
##  9 AAPL   2020-01-14  317.  318.  312.  313. 40488600     312.      -0.0135 
## 10 AAPL   2020-01-15  312.  316.  310.  311. 30480900     311.      -0.00429
## # … with 70 more rows

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 in microsoft because it has the bettern median and outliers of the two.

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.