sample2: Modified version of 'sample'.

View source: R/sample2.R

sample2R Documentation

Modified version of sample.

Description

Function sample, given the first parameter x is a single integer value, samples from the set 1,\ldots,x. This behavior might be undesirable when sample is embedded into routines and x is a variable. This function remedies this issue. If x is a number it returns x size-times.

Usage

sample2(x, size, replace = FALSE, ...)

Arguments

x

either a vector of one or more elements from which to choose, or a positive integer. See ‘Details.’

size

a non-negative integer giving the number of items to choose.

replace

should sampling be with replacement?

...

[any]
Further parameters passed down to sample, e.g. prob.

Value

A vector.


jakobbossek/re documentation built on Nov. 15, 2024, 1:42 a.m.