Skip to content

Instantly share code, notes, and snippets.

@frankandrobot
Last active March 27, 2019 04:21
Show Gist options
  • Save frankandrobot/cc017ebb25c68085ebddfae09b2523ff to your computer and use it in GitHub Desktop.
Save frankandrobot/cc017ebb25c68085ebddfae09b2523ff to your computer and use it in GitHub Desktop.
#' Calculate the real return on an index fund.
#'
#' @param yield - percent as a decimal
#' @param expense_ratio - percent as a decimal
#' @param balance
#' @param n - number of years
#'
#' @return
#' @examples
real_return_n <- function(yield, expense_ratio, starting_balance, n) {
return_n <- starting_balance
sapply(
1:n,
function(i) {
return_n <<- real_return(yield, expense_ratio, return_n)
})
return_n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment