[R] replicate rows

Petr PIKAL petr.pikal at precheza.cz
Fri Feb 3 13:35:39 CET 2012


Hi> 
> Hello,
> 
> I have a matrix of 17 rows and 20 columns. I want to replicate this 
matrix
> 20 times, but I only want to replicate the rows. How do I do that?

Replicate index.
x<-matrix(1:4, 2,2)
x[rep(1:2, 20),]

Regards
Petr

> 
> Kind regards / Met vriendelijke groet / Med venlig hilsen,
> 
> Dr. Gijs Schumacher
> Postdoctoral Researcher
> Department of Political Science and Public Management, University of 
> Southern Denmark &
> Department of Political Science, VU University Amsterdam
> 
> Email: gijs at sam.sdu.dk<mailto:gijs at sam.sdu.dk>; g.schumacher at vu.nl<
> mailto:g.schumacher at fsw.vu.nl>
> Web: http://www.gijsschumacher.nl<http://www.gijsschumacher.nl/>
> 
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list