Grokbase Groups R r-help March 2002
FAQ
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 6 | next ›
Discussion Overview
groupr-help @
categoriesr
postedMar 19, '02 at 3:08a
activeMar 28, '02 at 6:35a
posts6
users5
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase