you can use indexing, e.g., mat <- matrix(rnorm(20), 4, 5)
mat mat[rep(1:nrow(mat), 3), ] I hope it helps. Best, Dimitris Niccolò Bassani wrote:
Dear R users,I'm facing a trivial problem, but I really can't solve it. I've tried a dozen of codes, but I can't get the result I want. The question is: I have a dataframe like this one [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 2 5 5 4 9 [3,] 1 6 8 1 2 [4,] 8 6 4 1 5 made up of decimal numbers, of course. I want to append this dataframe to itself a number x of times, i.e. 3. That is I want a dataframe like this [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 2 5 5 4 9 [3,] 1 6 8 1 2 [4,] 8 6 4 1 5 [5,] 1 2 3 4 5 [6,] 2 5 5 4 9 [7,] 1 6 8 1 2 [8,] 8 6 4 1 5 [9,] 1 2 3 4 5 [10,] 2 5 5 4 9 [11,] 1 6 8 1 2 [12,] 8 6 4 1 5 I'm searching for an "authomatic" way to do this (I've already used the rbind re-writing x times the name of the frame...), as it must enter a function where one argument is exactly the number x of times to repeat this frame. Any ideas?? Thanks in advance! Niccolò [[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.
-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 ______________________________________________ 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.