Skip to contents

Provides the generic function sample() and methods to sample from transactions and associations.

Usage

# S4 method for class 'itemMatrix'
sample(x, size, replace = FALSE, prob = NULL, ...)

# S4 method for class 'associations'
sample(x, size, replace = FALSE, prob = NULL, ...)

Arguments

x

object to be sampled from (a set of associations or transactions).

size

sample size.

replace

a logical. Sample with replacement?

prob

a numeric vector of probability weights.

...

further arguments.

Value

An object of the same class as x.

Author

Michael Hahsler

Examples

data("Adult")

## sample with replacement
s <- sample(Adult, 500, replace = TRUE)
s
#> transactions in sparse format with
#>  500 transactions (rows) and
#>  115 items (columns)