[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):
http://s16.postimg.org/or2km30ph/equation.jpg
I've tried out out this code but it gave me error for writing brackets in function of summation:
>>>
x=matrix(c(6,2,1),3,1)
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