GerkeLab / fcds

Process data from the Florida Cancer Data System
https://gerkelab.github.io/fcds/
Other
3 stars 1 forks source link

age_group should still be ordered factor after age_adjust() #63

Closed gadenbuie closed 5 years ago

gadenbuie commented 5 years ago

I may have broken something when trying to speed up or maybe it's an uncaught edge case of refactor_single_levels().

gadenbuie commented 5 years ago

Closing because it seems to be working now, not sure what was going on when I created this issue.

library(fcds)
fcds:::fcds_version(FALSE)
#> [1] '0.0.8.9008'
fcds::fcds_example %>%
  count_fcds(sex = TRUE, race = TRUE) %>%
  complete_age_groups(sex, race, tidyr::nesting(year_group, year)) %>%
  age_adjust(keep_age = TRUE)
#> Warning: Column `year` has different attributes on LHS and RHS of join
#> # A tibble: 1,512 x 10
#> # Groups:   sex, race, year_group, year, age_group [1,512]
#>    sex   race  year_group year  age_group     n population std_pop      w
#>    <chr> <chr> <fct>      <chr> <ord>     <dbl>      <dbl>   <dbl>  <dbl>
#>  1 Male  White 1981-1985  1983  0 - 4         2     262707  1.90e7 0.0691
#>  2 Male  White 1981-1985  1983  5 - 9         0     237569  1.99e7 0.0725
#>  3 Male  White 1981-1985  1983  10 - 14       0     284983  2.01e7 0.0730
#>  4 Male  White 1981-1985  1983  15 - 19       1     320555  1.98e7 0.0722
#>  5 Male  White 1981-1985  1983  20 - 24       0     371853  1.83e7 0.0665
#>  6 Male  White 1981-1985  1983  25 - 29       2     375767  1.77e7 0.0645
#>  7 Male  White 1981-1985  1983  30 - 34       2     333727  1.95e7 0.0710
#>  8 Male  White 1981-1985  1983  35 - 39       2     290731  2.22e7 0.0808
#>  9 Male  White 1981-1985  1983  40 - 44       1     245117  2.25e7 0.0819
#> 10 Male  White 1981-1985  1983  45 - 49       7     217221  1.98e7 0.0721
#> # … with 1,502 more rows, and 1 more variable: rate <dbl>