[R] Repeat dataframe

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon May 1 18:52:44 CEST 2006


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




More information about the R-help mailing list