safe_sample: Safe sample function

View source: R/000_common.R

safe_sampleR Documentation

Safe sample function

Description

Similar to standard sample function. Safe sample function considering the special case of an integer vector with only one element.

Usage

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

Arguments

x

a vector with the alternatives to choose.

size

an integer with the number of elements to select from x.

replace

a boolean indicating if the elements should be chosen with replacement (default: FALSE).

prob

a double vector with the probability associated to each element (default: NULL).

Value

A vector with the elements chosen.


noisemodel documentation built on Oct. 17, 2022, 9:05 a.m.