@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user