[R] summation equation whose numerator has subscript

Sherouk Moawad sheroukmoawad at yahoo.com
Mon Nov 30 22:20:34 CET 2015

Dear R experts 
Please do you have any idea about how this summation can be written in R(the equation can be viewed in the following link): 

I've tried out out this code but it gave me error for writing brackets in function of summation:


for (l in 1:3){ 
sum(sapply(1:3, function(j[l]){if(l>1){sum(sapply(1:j[l-1], function(j[l]){x[j[l]]*(j[l]<j[l-1])}))}}))}>>>Thank you

More information about the R-help mailing list