I have a dataframe that looks as follows:
id amount number discount
1 400 10 0.7
2 500 5 0.7
3 600 10 0.6
df <- structure(list(id = 1:3, amount = c(400L, 500L, 600L), number = c(10L,
5L, 10L), discount = c(0.7, 0.7, 0.6)), class = "data.frame", row.names = c(NA,
-3L))
I have a formula, where N is the number column in the dataframe
So for the first row I would be summing:
400/(1+0.7)^0 + 400/(1+0.7)^1 + 400/(1+0.7)^2 +.... + 400/(1+0.7)^9
How could I do this for each row?
