Update plumbing

This commit is contained in:
Hadley Wickham 2022-09-22 09:01:02 -05:00
parent d0fca54370
commit 761fe9d591
3 changed files with 6 additions and 6 deletions

View File

@ -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)
```

View File

@ -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),

View File

@ -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)
```