From 2b2a35bb932a776257fd366b322a7f5539bb5b80 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 8 Mar 2023 17:41:23 -0600 Subject: [PATCH] Mention ties Fixes #1320 --- data-transform.qmd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/data-transform.qmd b/data-transform.qmd index 983f032..3319ec4 100644 --- a/data-transform.qmd +++ b/data-transform.qmd @@ -635,7 +635,12 @@ flights |> relocate(dest) ``` -This is similar to computing the max delay with `summarize()`, but you get the whole corresponding row instead of the single summary statistic. +Note that there are 105 destinations but we get 108 rows here. +What's up? +`slice_min()` and `slice_max()` keep tied values so `n = 1` means give me all rows with the highest value. +If you want exactly one row per group you can set `keep_ties = FALSE`. + +This is similar to computing the max delay with `summarize()`, but you get the whole corresponding row (or rows if there's a tie) instead of the single summary statistic. ### Grouping by multiple variables