How can I repeat a data.frame?

后端 未结 4 1477
Happy的楠姐
Happy的楠姐 2021-01-14 02:10

It\'s easy to repeat a data.frame once,

mt2 <- rbind(mtcars, mtcars)

But what\'s an R-like way to do this generally? If I want 10 copies

4条回答
  •  無奈伤痛
    2021-01-14 02:53

    @joran's answer is very elegant and you should use it if duplicating the rownames isn't required. However, this way will also duplicate the rownames:

    do.call(rbind, replicate(10, mtcars[1:10, ], simplify=FALSE))

提交回复
热议问题