Update plumbing
This commit is contained in:
parent
d0fca54370
commit
761fe9d591
|
@ -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:
|
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}
|
```{r}
|
||||||
df %>%
|
df |>
|
||||||
group_by(id, name) %>%
|
group_by(id, name) |>
|
||||||
summarize(n = n(), .groups = "drop") %>%
|
summarize(n = n(), .groups = "drop") |>
|
||||||
filter(n > 1L)
|
filter(n > 1L)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -423,7 +423,7 @@ If you commonly perform the same set of summaries when doing initial data explor
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
summary6 <- function(data, var) {
|
summary6 <- function(data, var) {
|
||||||
data %>% summarise(
|
data |> summarise(
|
||||||
min = min({{ var }}, na.rm = TRUE),
|
min = min({{ var }}, na.rm = TRUE),
|
||||||
mean = mean({{ var }}, na.rm = TRUE),
|
mean = mean({{ var }}, na.rm = TRUE),
|
||||||
median = median({{ var }}, na.rm = TRUE),
|
median = median({{ var }}, na.rm = TRUE),
|
||||||
|
|
|
@ -698,12 +698,12 @@ If these case studies have whetted your appetite for more real-life rectangling,
|
||||||
#| results: false
|
#| results: false
|
||||||
tibble(json = got_chars) |>
|
tibble(json = got_chars) |>
|
||||||
unnest_wider(json) |>
|
unnest_wider(json) |>
|
||||||
select(id, where(is.list)) %>%
|
select(id, where(is.list)) |>
|
||||||
pivot_longer(
|
pivot_longer(
|
||||||
where(is.list),
|
where(is.list),
|
||||||
names_to = "name",
|
names_to = "name",
|
||||||
values_to = "value"
|
values_to = "value"
|
||||||
) %>%
|
) |>
|
||||||
unnest_longer(value)
|
unnest_longer(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue