R/boot_func.R

Defines functions boot_func

Documented in boot_func

#' boot_func
#'
#' Resampling bootstrap of a vector for a given function.
#'
#' @param vec Vector to bootstrap resample from.
#' @param func Function to call on the samples.
#' @param resamples How many resamples to do.
#' @return Returns vector of length \code{resamples}, each from \code{func} applied to a bootstrap resample.
#' @export

boot_func <- function(vec, func, resamples = 100L) {
  rep_list <- lapply(1L:resamples, function(j) {
    func(sample(vec, replace = TRUE))
  })
  unlist(rep_list)
}
rzgross/uRbanmatching documentation built on Dec. 22, 2021, 8:20 p.m.