R/bootstrapR.R

Defines functions bootstrapR

Documented in bootstrapR

#' @title A bootstrap samples generator using R 
#' @description A function for generating bootstrap samples of given data using R
#' @param X the given set of one-dimension data
#' @param n the number of bootstraping
#' @return a matrix of samples generated by bootstraping and the row of the sample matrix is \code{n}
#' @examples
#' \dontrun{
#' X <- c(96,87,88,90,85)
#' outer <- bootstrapR(X, 10)
#' }
#' @export
bootstrapR <- function(X, n) {
  m <- length(X)
  out <- matrix(nrow = n, ncol = m)
  for(i in 1:n){
    out[i,] <- sample(X, m, replace = TRUE)
  }
  return(out)
}
SC19020/SC19020 documentation built on Jan. 3, 2020, 12:09 a.m.