--- Albert Picado <[EMAIL PROTECTED]> wrote: Albert
> Dear Uwe, > > Thanks for your answer. ----clip > De : Uwe Ligges <[EMAIL PROTECTED]> > � : Albert Picado <[EMAIL PROTECTED]> > Cc : [email protected] > Envoy� le : Samedi, 12 Ao�t 2006, 3h57mn 16s > Objet : Re: [R] adding columns to a table after a > loop > > > Albert Picado wrote: > > Dear list, > > > > I am trying to find the way to add columns to a > table > > (or a matrix) after a loop. The result of this > loop is > > an array and I would like to get all the results > in a > > single table once the loop is finish. I have > > reproduced a simplified example below: > > > >> a<- 1 > >> b <- matrix() > >> while (a <= 4) { > > + b<-rnorm(10) > > + a<- a +1 > > + } > > > Staying in your example: > > a <- 1 > b <- matrix(nrow=10, ncol=4) > while(a <= 4){ > b[,i] <- rnorm(10) > a <- a + 1 > } > > Uwe Ligges There is a minor typo in the above example. b[,1] should read b[,a]. It works very nicely with that small correction. ______________________________________________ [email protected] 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.
