Reputation: 1282
I have a summation from i=1 to 10 in 10.000/1/12^t = 56.502 In R :
n =10
t = seq(1,n,1);t
g = rep(0,n)
r = 0.12
for (i in t) {
g[i] = 10000/((1+r)^t[i])
GPV = sum(g)
}
GPV
Is there a quicker way other than for loop in R, in order to calculate this summation ?
Upvotes: 1
Views: 61
Reputation: 101343
Try this
> n <- 10
> r <- 0.12
> sum(10000 / (1 + r)^seq(n))
[1] 56502.23
Upvotes: 2