Open hadley opened 1 year ago
Note that the warning is not thrown inside a mutate call:
library(forcats)
library(dplyr, warn.conflicts = FALSE)
by_age <- gss_cat |>
count(age, marital) |>
mutate(
prop = n / sum(n),
.by = age
)
by_age |>
mutate(m = fct_reorder2(marital, age, prop)) |>
nrow()
#> Error in `mutate()`:
#> ℹ In argument: `m = fct_reorder2(marital, age, prop)`.
#> Caused by error:
#> ! `m` must be size 357 or 1, not 351.
by_age |>
mutate(m = fct_reorder2(marital, age, prop, .na_rm = FALSE)) |>
nrow()
#> [1] 357
Created on 2024-05-14 with reprex v2.1.0
Created on 2023-02-27 with reprex v2.0.2