slice_sample

Randomly sample rows from a DataFrame

Draws a random sample of n rows from a DataFrame, with or without replacement.

Parameters

Returns

A DataFrame containing the sampled rows.

Examples

mtcars |> slice_sample(n = 5)
mtcars |> slice_sample(n = 100, replace = true)

See Also

slice_min, slice_max, slice, set_seed, sample