Hi R list: How can I "repeat" a data frame n times (with n>1000), and obtain a new data frame where all the n data frames are binded by rows? Thank you for your help Kenneth -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Maybe the function "merge" is what you need. Xiaohua On 5/1/06, Kenneth Cabrera <krcabrer@epm.net.co> wrote:> > Hi R list: > > How can I "repeat" a data frame n times (with n>1000), > and obtain a new data frame where all the n data frames > are binded by rows? > > Thank you for your help > > Kenneth > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >[[alternative HTML version deleted]]
Well, I find a solution! If DFe is a data frame and n is an integer then DFr<-data.frame(t(matrix(rep(t(DFe),n),dim(DFe)[2],dim(DFe)[1]*n))) names(DFr)<-names(DFe) Will work!! Maybe somebody has a more elegant solution. Again, thank you for your help. On Mon, 01 May 2006 11:23:14 -0500, Kenneth Cabrera <krcabrer at epm.net.co> wrote:> Hi R list: > > How can I "repeat" a data frame n times (with n>1000), > and obtain a new data frame where all the n data frames > are binded by rows? > > Thank you for your help > > Kenneth >-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
On Mon, 1 May 2006, Kenneth Cabrera wrote:> Hi R list: > > How can I "repeat" a data frame n times (with n>1000), > and obtain a new data frame where all the n data frames > are binded by rows?Perhaps my_df[rep(1:nrow(my_df), times=n), ] is what you want? -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595