#' Calculate CAGR
#'
#' Calculates the Compound Annual Growth Rate (CAGR).
#' @param value_begin The value at the start of the series.
#' @param value_end The value at the end of the series.
#' @param n_periods The number of periods to base the CAGR calculations on.
#'
#' @seealso http://www.investopedia.com/terms/c/cagr.asp
#'
#' @export
CAGR <- function(value_begin, value_end, n_periods){
((value_end / value_begin) ^ (1 / n_periods)) - 1
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.