You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(tidyverse)
library(fcds)
fcds<- fcds_load()
# work with random subsamplefcds<-fcds %>% group_by(!!!rlang::syms(fcds_vars("demo"))) %>% sample_n(1) %>% ungroup()
If we do the regrouping first, age_adjust() will ultimately fail.
fcds_regrouped<-fcds %>%
separate_age_groups() %>%
mutate(
age_group= case_when(
age_high<20~"< 20",
age_high<50~"20 - 49",
age_high<60~"50 - 64",
age_high<85~"65 - 84",
TRUE~"85 +"
),
age_group= fct_reorder(age_group, age_low)
)
fcds_vars(.data=fcds_regrouped, "demo")
#> # A tibble: 14,815 x 8#> age_group race sex origin marital_status birth_country birth_state#> <fct> <fct> <fct> <fct> <fct> <fct> <fct> #> 1 < 20 White Male Non-H… Married; Unma… US States an… Florida #> 2 < 20 White Male Non-H… Single, Separ… US States an… Florida #> 3 < 20 White Male Non-H… Single, Separ… US States an… Florida #> 4 < 20 White Male Non-H… Single, Separ… US States an… Florida #> 5 < 20 White Male Non-H… Single, Separ… US States an… Florida #> 6 < 20 White Male Non-H… Single, Separ… US States an… Florida #> 7 < 20 White Male Non-H… Single, Separ… US States an… Florida #> 8 < 20 White Male Non-H… Single, Separ… US States an… Other US S…#> 9 < 20 White Male Non-H… Single, Separ… US States an… Other US S…#> 10 < 20 White Male Non-H… Single, Separ… US States an… Other US S…#> # … with 14,805 more rows, and 1 more variable: primary_payer <fct>fcds_regrouped %>%
count_fcds() %>%
age_adjust(keep_age=TRUE)
#> The age groups in `data` do not match any age groups in#> `population_standard`.
The current way around this is to do the re-grouping after the age adjustment.
But the re-grouped ages overlap the underlying standard ages, so age_adjust() could have called standardize_age_groups() on the population data relative to the input data to do this for us.
The text was updated successfully, but these errors were encountered:
If age groups don't match, then what?
If we do the regrouping first,
age_adjust()
will ultimately fail.The current way around this is to do the re-grouping after the age adjustment.
But the re-grouped ages overlap the underlying standard ages, so
age_adjust()
could have calledstandardize_age_groups()
on the population data relative to the input data to do this for us.The text was updated successfully, but these errors were encountered: