[R] Question
Ambrosini Alessandro
klavan at tiscalinet.it
Tue May 14 14:13:39 CEST 2002
Hello. I want to use "for".
I have a matrix called "mat" that has got 100 rows.
I want to take the line 1 and make
a1<-which(mat[1,]==1)
After this I want to take the second row and make
a2<-which(mat[2,]==1)
and so on until I arrive at row 100.
I want to make it automatic for the 100 rows and so I wrote:
for(i in 1:nrow(mat)){
ai<-which(mat[i,]==1)
}
but it doesn't work.
I need to obtain 100 vectors called a1,a2,a3,...,a100.
Please help me.
Alessandro
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list