sampled: Bug free Redefinition of Sample Function

View source: R/other_functions.R

sampledR Documentation

Bug free Redefinition of Sample Function

Description

If only one value is given in sample function, it chooses a value between 1 and the number you specified. The redefined sample function solves this problem.

Usage

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

Arguments

x

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

size

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

replace

should sampling be with replacement?

prob

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

Value

For sample a vector of length size with elements drawn from either x or from the integers 1:x.

Author(s)

Omer Kara

References

For more information see sample.

Examples

sampled(2, 1)
sampled(1:5, 2)


omerkara/okara documentation built on Nov. 21, 2023, 7:56 p.m.