Francisco J Molina
2002-Mar-19 03:08 UTC
[R] matrix with fix number columns but variable number rows
I have to store a number of vectors of the same length. I know the length but I do not know the number of vectors. How can I store them as they are created (they are created one by one)? -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Uwe Ligges
2002-Mar-19 07:38 UTC
[R] matrix with fix number columns but variable number rows
Francisco J Molina wrote:> > I have to store a number of vectors of the same length. I know the > length but I do not know the number of vectors. > > How can I store them as they are created (they are created one by one)?*Please* read "An Introduction to R"! rbind() and indexing a matrix M[i, j] are possible solutions. Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Sven Garbade
2002-Mar-19 09:06 UTC
[R] matrix with fix number columns but variable number rows
Francisco J Molina wrote:> I have to store a number of vectors of the same length. I know the > length but I do not know the number of vectors. > > How can I store them as they are created (they are created one by one)?Maybe data <- vector(mode="numeric") # and here functions, loops or whatever to read the data newdata <- datafromanywhere data <- rbind(data, newdata) Regards, Sven -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Agustin Lobo
2002-Mar-19 09:24 UTC
[R] matrix with fix number columns but variable number rows
If the vectors are created within a loop, matriz <- NULL for(...){ ... matriz <- cbind(matriz,vector) } matriz but I think that it's better to define matriz with a large number of cols and avoid growing the matrix within the loop: matriz <- matrix(NULL,nrow=numlineas,ncol=maxnumcols) col <- 0 for(...){ col <- col+1 ... matriz[,col] <- vector } matriz <- matriz[,1:col] #keep only the used cols matriz ..and even better if you can avoid the loop, R offers many opportunities for that. Dr. Agustin Lobo Instituto de Ciencias de la Tierra (CSIC) Lluis Sole Sabaris s/n 08028 Barcelona SPAIN tel 34 93409 5410 fax 34 93411 0012 alobo at ija.csic.es On Mon, 18 Mar 2002, Francisco J Molina wrote:> I have to store a number of vectors of the same length. I know the > length but I do not know the number of vectors. > > How can I store them as they are created (they are created one by one)? > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Agustin Lobo
2002-Mar-19 11:48 UTC
[R] matrix with fix number columns but variable number rows
On Tue, 19 Mar 2002, Agustin Lobo wrote:> matriz <- matrix(NULL,nrow=numlineas,ncol=maxnumcols)Actually I had not tried it, it should be, i.e. matriz <- matrix(0,nrow=numlineas,ncol=maxnumcols) as with NULL we cannot fill a matrix Agus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
E. D. Isaia
2002-Mar-28 06:35 UTC
[R] matrix with fix number columns but variable number rows
Is that you mean? X<-cbind(c(10,12,13,11),c(20,25,24,22),c(50,45,54,58))> dim(X)[1] 4 3 Best, isaia. Francisco J Molina wrote:> I have to store a number of vectors of the same length. I know the > length but I do not know the number of vectors. > > How can I store them as they are created (they are created one by one)? > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Ennio D. Isaia ~ Dep. of Statistics & Mathematics, University of Torino ~ Piazza Arbarello, 8 - 10128 Torino (Italy) ~ Phone: +39 011 670 62 51 ~~ Fax: +39 011 670 62 39 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._