R/sample_n_or_bust.R

Defines functions sample_n_or_bust

Documented in sample_n_or_bust

#' Sample a dataframe for n obs and returns full dataframe if n > nrow
#' @param n number of observations
#' @param ... additional arguments for dplyr::sample_n function
#' @importFrom dplyr sample_n
#' @importFrom dplyr distinct
#' @export

sample_n_or_bust <-
  function(dataframe, n, ...) {
    dplyr::sample_n(tbl = tbl, size = n, replace = TRUE, ...) %>%
                        dplyr::distinct()
  }
patelm9/somersault2 documentation built on Dec. 16, 2019, 12:45 a.m.