R/repeat.R

#' Repeat a data.frame
#'
#' @description Copy and append data.frame to itself.
#' @details May be useful to use \code{dplyr::group_by()} and or \code{tidyr::nest()} before
#' calling this function.
#' @param data data.frame.
#' @param times numeric. Number of times to replicate \code{data}.
#'
#' @return data.frame
#' @export
repeat_df <- function(data, times) {
  data[rep(seq_len(nrow(data)), times), ]
}
aelhabr/temisc documentation built on May 28, 2019, 3:55 p.m.