[R] "ciclo for" in matrix construction ( matlab -> R )

From: massimodisasha <massimodisasha_at_yahoo.it>
Date: Wed 04 Oct 2006 - 15:06:54 GMT


hi,
i'm new to R
i have a little script in matlab....
now i'm porting it to R but i've some problem. how can i write in R language this
matlab/octave code:

LX = L ;                     >>> L is a matrix
ss = size(LX,1);
E_N_2 = zeros(ss,2);

for i = 1:ss
E_2 = E_0 + LX(i,1)*C(3)+LX(i,2)*C(4); >>>> E_0 , C(3), c(4) are costant
N_2 = N_0 + LX(i,2)*C(3)-LX(i,1)*C(4);
r=[ E_2,N_2];
E_N_2(i,:)=r;
end
E_N_2

i'm try so :

library(matlab)

LX <- L
ss <- dim(LX)
ss <- ss[1]

E_N_2 <- zeros(ss,2)
for(i in 1:ss)
.....
.....?

thanks for any help :-)
Massimo

my mayor problem is to know how the "cicle for" works

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
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. Received on Thu Oct 05 01:11:59 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 04 Oct 2006 - 15:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.