for loop - How to express this sum concisely in R? -
i have simple r
beginner's question:
how express sum below concisely in r
?
sum_{i=1}^n / (a+i)
i tried following, there must better way, without calling for
:
r<-0 for(i in 1:n){ r <- r + (a / (a+i)) }
thanks!
i believe it's simple as:
sum(a/(a+1:n))
Comments
Post a Comment