Learn R Programming

arules (version 0.2-1)

sample: Random Samples and Permutations

Description

Provides the generic function sample and the S4 method to take a sample of the specified size from the elements of x using either with or without replacement. sample can be used to sample from transactions.

Usage

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

Arguments

x
object to be sampled from.
size
sample size.
replace
logical; sample with replacement?
prob
a vector of probability weights.

Value

  • An object of the same class as x.

See Also

itemMatrix-class.

Examples

Run this code
data("Adult_transactions")

## sample with replacement
s <- sample(Adult_transactions, 500, replace = TRUE)
s

Run the code above in your browser using DataLab