mahmoudfarid30 at yahoo.com
2016-Apr-08 13:54 UTC
[R] write a function inside the summation in a more condensed form
Dear R Experts that's my original equation> x=c(2,4)> Y1=sum(sapply(1:2,function(i){sum(sapply(1:i,function(j){(3^(x[i]+x[j]))}))})) > y1[1] 7371 I want to write the inside function (3^(x[i]+x[j])) in a more condensed form cause this will help me when the multiple summations are more than two I've tried the following form> y2=sum(sapply(1:2,function(i){sum(sapply(1:i,function(j){(3^(sum(sapply(i:j,function(l){x[l]}))))}))})) > y2[1] 819 But it didn't work, it gave another solution Any help or recommendations
S Ellison
2016-Apr-11 15:27 UTC
[R] write a function inside the summation in a more condensed form
> I want to write the inside function (3^(x[i]+x[j])) in a more condensed form > cause this will help me when the multiple summations are more than twoindices<-c(i,j) #or whatever you want 3^sum( x[indices] ) S Ellison ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}