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: 206 x 8
## # Groups:   symbol [2]
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 AAPL   2019-01-02  155.  159.  154.  158. 37039700     156.
##  2 AAPL   2019-01-03  144.  146.  142   142. 91312200     141.
##  3 AAPL   2019-01-04  145.  149.  144.  148. 58607100     147.
##  4 AAPL   2019-01-07  149.  149.  146.  148. 54777800     146.
##  5 AAPL   2019-01-08  150.  152.  149.  151. 41025300     149.
##  6 AAPL   2019-01-09  151.  155.  150.  153. 45099100     151.
##  7 AAPL   2019-01-10  152.  154.  151.  154. 35780700     152.
##  8 AAPL   2019-01-11  153.  154.  152.  152. 27023200     150.
##  9 AAPL   2019-01-14  151.  151.  149.  150  32439200     148.
## 10 AAPL   2019-01-15  150.  153.  150.  153. 28710900     151.
## # … with 196 more rows
## # A tibble: 206 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   2019-01-02  155.  159.  154.  158.  3.70e7     156.       0      
##  2 AAPL   2019-01-03  144.  146.  142   142.  9.13e7     141.      -0.0996 
##  3 AAPL   2019-01-04  145.  149.  144.  148.  5.86e7     147.       0.0427 
##  4 AAPL   2019-01-07  149.  149.  146.  148.  5.48e7     146.      -0.00223
##  5 AAPL   2019-01-08  150.  152.  149.  151.  4.10e7     149.       0.0191 
##  6 AAPL   2019-01-09  151.  155.  150.  153.  4.51e7     151.       0.0170 
##  7 AAPL   2019-01-10  152.  154.  151.  154.  3.58e7     152.       0.00320
##  8 AAPL   2019-01-11  153.  154.  152.  152.  2.70e7     150.      -0.00982
##  9 AAPL   2019-01-14  151.  151.  149.  150   3.24e7     148.      -0.0150 
## 10 AAPL   2019-01-15  150.  153.  150.  153.  2.87e7     151.       0.0205 
## # … with 196 more rows

Q1 Calculate mean daily returns for each stock.

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

## # A tibble: 2 x 2
##   symbol mean_returns
##   <chr>         <dbl>
## 1 AAPL        0.00144
## 2 MSFT        0.00228

Q2 Plot mean daily returns using bar charts.

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

Q3 Rename the stocks as Apple and Microsoft.

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

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

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

Q5 Label the bars with mean daily returns.

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

Q6 Add labels to the axes.

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

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

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

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

Hint: See the code in 4.3.3 Box plots.

Q8 Hide the messages and the code, but display results of the code from 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.