Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
compound <- function(start, growthrate_percent, fees_percent, years=15) {
amount <- start
growthrate_proportion <- growthrate_percent/100
fees_proportion <- fees_percent/100
yearly_vals <- rep(NA, years)
for(year in 1:years) {
amount <- amount*(1+growthrate_proportion) - amount*fees_proportion
yearly_vals[year] <- amount
plot(x=1:years,y=yearly_vals, pch=16, cex=2, ylab="total value in dollars", xlab="year", main=sprintf("growing at %.3f%% with fees of $%.3f%%\nstarting value: $%.2f\nending value: $%.2f",growthrate_percent, fees_percent,start, amount))
#plot(x=1:years,y=yearly_vals,add=T, type=line())
compound(start=100, growthrate_percent = 5, fees_percent = 0, years = 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.