diff --git a/data-tidy.qmd b/data-tidy.qmd index c790473..86abd9d 100644 --- a/data-tidy.qmd +++ b/data-tidy.qmd @@ -569,9 +569,9 @@ df |> pivot_wider( Since you don't know how to work with this sort of data yet, you'll want to follow the hint in the warning to figure out where the problem is: ```{r} -df %>% - group_by(id, name) %>% - summarize(n = n(), .groups = "drop") %>% +df |> + group_by(id, name) |> + summarize(n = n(), .groups = "drop") |> filter(n > 1L) ``` diff --git a/functions.qmd b/functions.qmd index a159cb3..23da97b 100644 --- a/functions.qmd +++ b/functions.qmd @@ -423,7 +423,7 @@ If you commonly perform the same set of summaries when doing initial data explor ```{r} summary6 <- function(data, var) { - data %>% summarise( + data |> summarise( min = min({{ var }}, na.rm = TRUE), mean = mean({{ var }}, na.rm = TRUE), median = median({{ var }}, na.rm = TRUE), diff --git a/rectangling.qmd b/rectangling.qmd index f2bf193..42d4ba4 100644 --- a/rectangling.qmd +++ b/rectangling.qmd @@ -698,12 +698,12 @@ If these case studies have whetted your appetite for more real-life rectangling, #| results: false tibble(json = got_chars) |> unnest_wider(json) |> - select(id, where(is.list)) %>% + select(id, where(is.list)) |> pivot_longer( where(is.list), names_to = "name", values_to = "value" - ) %>% + ) |> unnest_longer(value) ```