Randomly sample rows from a DataFrame
Draws a random sample of n rows from a DataFrame, with or without replacement.
data (DataFrame): The input
DataFrame.
n (Int): = 1 Number of rows to
sample.
replace (Bool): = false Sample with
replacement.
A DataFrame containing the sampled rows.
mtcars |> slice_sample(n = 5)
mtcars |> slice_sample(n = 100, replace = true)