bsample: Clone of 'sample' without weird behaviour for length(x)==1.

View source: R/utils.R

bsampleR Documentation

Clone of sample without weird behaviour for length(x)==1.

Description

Identical to sample but when x is an integer it just returns x rather than an integer in 1:x (which is what sample does).

Usage

bsample(x, size, replace = FALSE, prob = NULL)

Arguments

x

Either a vector of one or more elements from which to choose, or a positive integer. See sample for details.

size

a positive number, the number of items to choose from.

replace

Should sampling be with replacement?

prob

A vector of probability weights for obtaining the elements of the vector being sampled.


david-borchers/hmltm documentation built on Oct. 29, 2023, 9:07 p.m.