[R] matlab code into R

Phil Spector spector at stat.berkeley.edu
Thu Nov 4 20:28:52 CET 2010


Well, there's the obvious:

N = matrix(0,n-1,n-1)
for(i in 2:(n-1))
      N[1,i] = 1/(pi * (i-1))
for(i in 2:(n-2))
    for(j in i:(n-1))
       N[i,j] = N[i-1,j-1]
for(i in 2:(n-1))
    for(j in 1:i)
       N[i,j] = -N[j,i]

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu



> Hello,
>
> I'm trying to write the following matlab code into R:
>
> N = zeros(n-1); for i=2:(n-1)
>
> N(1,i) = 1/(pi * (i-1));
>
> end for i=2:(n-2)
>
> for j=i:(n-1) N(i,j) = N(i-1,j-1);
>
> end;
>
> end for i=2:(n-1)
>
> end
>
> for j=1:i N(i,j) = -N(j,i);
>
> end;
>
>
> any suggestions?
>
>
> Thanks
>
>
> can i just add the following line to my calculation N=1/(pi*(i-1)
>
> -- 
> Marcelo Andrade de Lima
> UNIFESP - Universidade Federal de S?o Paulo
> Departamento de Bioqu?mica
> Disciplina de Biologia Molecular
> Rua Tr?s de Maio 100, 4 andar - Vila Clementino, 04044-020
> Lab +55 11 55764438 R.1188
> Cell +55 11 92725274
> mlima at unifesp.br
>
> 	[[alternative HTML version deleted]]
>
>



More information about the R-help mailing list