Last active
March 27, 2019 04:21
-
-
Save frankandrobot/cc017ebb25c68085ebddfae09b2523ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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