[R] code for double sum

Jim Lemon jim at bitwrit.com.au
Wed Jun 3 12:25:51 CEST 2009


Roslina Zakaria wrote:
> Hi R-users,
>  
> I wrote a code to evaluate double sum as follows: 
>  
> ff2 <- function(bb,eta,z,k)
> { r <- length(z)
> for (i in 1:r) 
> { sm1 <- sum((z[i]*bb/2)*(psigamma((0:k)+eta+1,deriv=0)/(factorial(0:k)*gamma((0:k)+eta+1))))
>  sm2 <- sum((besselI(z[i]*bb,eta)*log(z[i]*bb/2) - sm1)/besselI(z[i]*bb,eta))
>  sm2
> }
> ff2(bb,eta,z,10)
>  
>  
> but it gave me the following message:
>  
>   
>> source(.trPaths[5], echo=TRUE, max.deparse.length=10000)
>>     
> Error in source(.trPaths[5], echo = TRUE, max.deparse.length = 10000) : 
>   C:\Documents and Settings\zakry001\Application Data\Tinn-R\tmp\selection.r: unexpected end of input at
> 9: )
>   
>> ff2(bb,eta,z,10)
>>     
> Error in ff2(bb, eta, z, 10) : unused argument(s) (10)
>   
Hi Rosalina,
You're missing one right brace in your function definition.
Jim




More information about the R-help mailing list