I have a simple R
beginner's question:
How do I express the sum below most concisely in R
?
sum_{i=1}^n a / (a+i)
I tried the following, but there must be a better way, without actually calling for
:
r<-0
for(i in 1:n){ r <- r + (a / (a+i)) }
Thanks!