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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -