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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi Alessandro,> -----Original Message----- > From: Ambrosini Alessandro [mailto:klavan at tiscalinet.it] > Sent: Tuesday, May 14, 2002 10:14 PM > To: R-help > Subject: [R] Question > > Hello. I want to use "for".[WNV] Are you sure?> 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.[WNV] Do you really want 100 separate objects? Would a list of 100 answers do? Here is one way to make a list with the vectors you want aList <- apply(mat, 1, function(x) which(x == 1)) Then aList[[i]] is what you would call ai If you really do want 100 separate objects you can do that as a further step for(i in 1:100) assign(paste("a", i, sep=""), aList[[i]]) but that seems an awkward thing to do to me. <begin sermon> S (respectively R) encourages you to take the "whole object" view of a calculation. An extension of that is to take the "whole problem" view in asking for help. Rather than form a fixed view on how a problem is to be solved it is better to present the whole problem to see if someone has an elegant strategy for the whole thing you may not have anticipated. Now that you have the 100 objects, what are you going to do with them, for example. I know there are ways in SAS, SPSS and even Genstat for dealing with specially named objects in sequence, but such devices are a bit more complex in S (resp R) and simpler methods are available. <end sermon>> 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello. In some cases, when I use Chi-squared test with simulate value I obtain Pearson's Chi-squared test with simulated p-value (based on 2000 replicates) data: a X-squared = 226.1085, df = NA, p-value = < 2.2e-16 What does "p-value = < 2.2e-16" mean? Is my p-value result smaller than 2.2e-16? Thank you 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hallo, I have a Problem. Maybe you can help me. I want to call single commands in Rterm.exe (for example: read.table(....), image,.....) directly with my Programm (written in VC++ for WindowsNT 4.0). I thought on a possibility, that I can give single commands to the command line of Rterm.exe by sending the command via write or printf or so, like you can write in the command line of RGui.exe via the keyboard. Is there such a possibility or something similar, or must I use a BATCH-File. Thanks for helping me! e - mail: lacen at eos-gmbh.de -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Lacen at EOS-GmbH.de wrote:> > Hallo, > I have a Problem. Maybe you can help me. > > I want to call single commands in Rterm.exe (for example: read.table(....), > image,.....) directly with my Programm (written in VC++ for WindowsNT 4.0). > I thought on a possibility, that I can give single commands to the command > line of Rterm.exe by sending the command via write or printf or so, like you > can write in > the command line of RGui.exe via the keyboard. > Is there such a possibility or something similar, or must I use a > BATCH-File.For example you can pipe it to rterm. Simple example: c:/> echo 1+1 | rterm --slave [1] 2 Hint: A file ...\src\gnuwin32\README.rterm exists. Uwe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello, Is there an easy way to color code the labels shown in plots of a hierarchical clustering or did I just not read the documentation properly? Kind regards, hinrich d8-) ============================================Hinrich Goehlmann, PhD Johnson & Johnson Pharmaceutical Research & Development Genomic Technologies Turnhoutseweg 30 2340 Beerse Belgium Phone: +32-(0)14/60.71.21 Fax: +32-(0)14/60.61.11 ============================================ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._