# sampling =============================================
#' Random sampling of entries
#' @param x population from which to sample entries
#' @param ... parameters for `sample.int`
#' @export
sample_random <- function(x, ...) {
x = as.matrix(x)
idxs = sample.int(length(x), ...)
x[idxs]
}
#' Random sampling of rows
#' @param x population from which to sample rows
#' @param ... parameters for `sample.int`
#' @export
sample_rows <- function(x, ...) {
x = as.matrix(x)
idxs = sample.int(nrow(x), ...)
x[idxs, , drop=FALSE]
}
#' Random sampling of columns
#' @param x population from which to sample columns
#' @param ... parameters for `sample.int`
#' @export
sample_cols <- function(x, ...) {
x = as.matrix(x)
idxs = sample.int(ncol(x), ...)
x[, idxs, drop=FALSE]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.