Re: [R] Matlab code to R code

2012-10-22 Thread Berend Hasselman
On 22-10-2012, at 09:49, Roslina Zakaria wrote: > Dear r-users, > > I would like to convert my Matlab code to R-code, however it dies not work as > expected. Hope somebody can help me to match Matlab and r codes. > > R code: > > rr <- function(r,cxn) > { > tol <- 1E-4; > > for(i in 1:n) > {

[R] Matlab code to R code

2012-10-22 Thread Roslina Zakaria
Dear r-users, I would like to convert my Matlab code to R-code, however it dies not work as expected.  Hope somebody can help me to match Matlab and r codes. R code: rr <- function(r,cxn) { tol <- 1E-4; for(i in 1:n) { t1 <- (1+(i-1)*r)*log((1+(i-1)*r)) t2 <- (i-1)*(1-r)*log(1-r) rri <- ((t1+t