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

______________________________________________
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.

Reply via email to