Dear all, Here is one more way to go though using rep() and then matrix(): > rows <- 1:3 > matrix(rep(rows,5),ncol=5) [,1] [,2] [,3] [,4] [,5] [1,] 1 1 1 1 1 [2,] 2 2 2 2 2 [3,] 3 3 3 3 3
HTH, Jorge On Tue, Feb 24, 2009 at 1:43 PM, Gabor Grothendieck <ggrothendi...@gmail.com > wrote: > Suppose we want 3 rows and the ith row should have 5 columns of i. > Create a list whose ith component is the ith row and rbind them: > > > rows <- 1:3 > > do.call(rbind, lapply(rows, rep, 5)) > [,1] [,2] [,3] [,4] [,5] > [1,] 1 1 1 1 1 > [2,] 2 2 2 2 2 > [3,] 3 3 3 3 3 > > > On Tue, Feb 24, 2009 at 1:01 PM, Alexy Khrabrov <delivera...@gmail.com> > wrote: > > I'm growing a large dataframe by composing new rows and then doing > > > > row <- compute.new.row.somehow(...) > > d <- rbind(d,row) > > > > Is this a fast/preferred way? > > Cheers, > > Alexy > > > > ______________________________________________ > > R-help@r-project.org 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. > > > > ______________________________________________ > R-help@r-project.org 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.