On Oct 14, 2015, at 1:29 PM, Sherouk Moawad via R-help wrote: > Σi=02 Σj=01(exp(xi+xj)), i>j if (i>0 and j>0) I want to write this > summation which has a condition on numerator(j<i)i>0 and j>0I tried on this > code
That comes across as only barely comprehensible. > sum(sapply(0:2, function(i){sum(sapply(0:1, function(j){if > (i>0&j>0){i>j}{exp(x[i]+x[j])}))}))But it didn't work Any help please > [[alternative HTML version deleted]] You should learn to post in plain text. This IS a plain text mailing list. It is generally effective to include Boolean logic in the summand. Try this untested modification: sum( sapply(0:2, function(i){ sum( sapply(0:1, function(j){ (i>0)*(j>0)(i>j)*(exp(x[i]+x[j]) )))) ) -- David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.