How can I repeat a data.frame?

后端 未结 4 1451
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:37

    dplyr-based solution (from here)

    library(dplyr)
    mtcars %>% slice(rep(1:n(), 2))  # 2 copies of data frame
    

提交回复
热议问题