Re: [R] add repeated rows in data frame (without a loop)

2011-02-22 Thread Nicolas Gutierrez
That worked.. thanks Peter On 2/22/2011 5:40 PM, Peter Ehlers wrote: popm <- as.matrix(pop) recm <- matrix(rep(rec, n), nr=n, byrow=TRUE) newpop <- data.frame(rbind(popm, recm)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

Re: [R] add repeated rows in data frame (without a loop)

2011-02-22 Thread Peter Ehlers
On 2011-02-22 14:48, Nicolas Gutierrez wrote: Hi All, I have a data frame "pop": > id xloc yloc size > 1 1 101295 > 2 211 1081 And I want to add the vector "rec" to the data frame "n" times (without using a loop): > rec=c(3, 5, 5, 10) > n=2 Th

[R] add repeated rows in data frame (without a loop)

2011-02-22 Thread Nicolas Gutierrez
Hi All, I have a data frame "pop": >id xloc yloc size > 1 1 101295 > 2 211 1081 And I want to add the vector "rec" to the data frame "n" times (without using a loop): > rec=c(3, 5, 5, 10) > n=2 The result I want: >id xloc yloc size > 1 1 10