Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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 a set of transactions or associations.

Usage

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(s)

Michael Hahsler

See Also

Examples

data("Adult")

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

arules

Mining Association Rules and Frequent Itemsets

v1.6-7
GPL-3
Authors
Michael Hahsler [aut, cre, cph], Christian Buchta [aut, cph], Bettina Gruen [aut, cph], Kurt Hornik [aut, cph], Ian Johnson [ctb, cph], Christian Borgelt [ctb, cph]
Initial release
2021-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.