From d06d4129e62af3a73badf6647dba1308a91b8d77 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Fri, 18 Nov 2022 15:27:05 -0600 Subject: [PATCH] Fix slice_sample() typo Fixes #1131 --- data-transform.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-transform.qmd b/data-transform.qmd index 12a4202..0614450 100644 --- a/data-transform.qmd +++ b/data-transform.qmd @@ -471,7 +471,7 @@ There are five handy functions that allow you pick off specific rows within each - `df |> slice_tail(n = 1)` takes the last row in each group. - `df |> slice_min(x, n = 1)` takes the row with the smallest value of `x`. - `df |> slice_max(x, n = 1)` takes the row with the largest value of `x`. -- `df |> slice_sample(x, n = 1)` takes one random row. +- `df |> slice_sample(n = 1)` takes one random row. You can vary `n` to select more than one row, or instead of `n =`, you can use `prop = 0.1` to select (e.g.) 10% of the rows in each group. For example, the following code finds the most delayed flight to each destination: