urnsamples: Sampling from Urns

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function creates a sample space associated with the experiment of sampling distinguishable objects from an urn.

Usage

1
2
3
4
5
6
7
urnsamples(x, ...)

## Default S3 method:
urnsamples(x, size, replace = FALSE, ordered = FALSE, ...)

## S3 method for class 'data.frame'
urnsamples(x, size, replace = FALSE, ordered = FALSE, ...)

Arguments

x

a vector or data frame from which sampling should take place.

size

number indicating the sample size.

replace

logical indicating whether sampling should be done with replacement.

ordered

logical indicating whether order among samples is important.

...

further arguments to be passed to or from other methods.

Details

The function operates on the indices of the urn (or rows, in the case urn is a data frame). It then takes those samples and substitutes back into urn to generate the entries of the data frame (or list, respectively). In the case that urn has repeated values, the result will be repeated values in the output.

Note that urnsamples strips x of any existing probs column before sampling.

Value

A data frame if urn is a vector, and a list if urn is a data frame.

Author(s)

G. Jay Kerns gkerns@ysu.edu.

See Also

iidspace, probspace nsamp

Examples

1
2
3
urnsamples(1:10, size = 5)
S <- cards()
urnsamples(S, size = 2)

aflaherty13/prob documentation built on May 28, 2019, 4:42 p.m.