November 2016
Beginner to intermediate
959 pages
43h 46m
English
The density plot uses the kernel density estimation to generate the distribution. In this recipe, we will utilize the density() function to generate a plot. The density plots can be used to study the underlying distribution of the data.

We will use the quantmod package to download the stock prices for Microsoft and also calculate monthly returns:
install.packages("quantmod")
library(quantmod)We will download the data in R using the getSymbols() function. Once we have the data, we can calculate the monthly returns using the monthlyReturns() function:
prices = c("MSFT") getSymbols(prices) msft_m = monthlyReturn(MSFT) ...Read now
Unlock full access