[R] a question on matrix manipulation

Lei Liu liulei at virginia.edu
Wed Jun 17 07:54:55 CEST 2009


Hi there,

I have a question on manipulating a matrix. Say I have a matrix A 
with 3 rows. I want to generate a new matrix B with 3 duplicates of 
the first row of A, 2 duplicates of the second row, and 4 duplicates 
of the third row. So B is a matrix with 9 rows. Or more general, I 
want to generate (3, 2, 4, 5) duplicates of rows 1-4 of a matrix with 
4 rows. Is there a simple function to do it? Thanks a lot!

Lei




More information about the R-help mailing list