R4EPI / epitabulate

Tables for epidemiological analysis
https://R4EPI.github.io/epitabulate
GNU General Public License v3.0
8 stars 0 forks source link

gt_mr missing? #22

Open nsbatra opened 2 years ago

nsbatra commented 2 years ago

Hi @amygimma , it's 3am so hope this is coherent, else @aspina7 can fill in the details. Any help greatly appreciated. Trying to wrap this up ASAP.

I am working in the outbreak templates updating the tables to gtsummary using your functions. Currently in AJS template in this branch.

Trying to recreate the general ( no sub groups) attack rate table created with this:

ar <- attack_rate(nrow(linelist_cleaned), population, multiplier = 10000)

ar %>%
  merge_ci_df(e = 3) %>% # merge the lower and upper CI into one column
  rename("Cases (n)" = cases, 
         "Population" = population, 
         "AR (per 10,000)" = ar, 
         "95%CI" = ci) %>% 
  select(-Population) %>% # drop the population column as it is not changing
  knitr::kable(digits = 1, align = "r")

And was trying to use code you wrote

gt_ar <- linelist_cleaned %>%
    gtsummary::tbl_summary(
      include = case,
      statistic = case ~ "{n}",
      label = case ~ "Case")  %>%
    add_ar(case_var = "case", multiplier = 10000)

But the error I get is:

Error in "Cases" %in% names(gt_mr$table_body) : object 'gt_mr' not found
3. "Cases" %in% names(gt_mr$table_body)
2. add_ar(., case_var = "case", multiplier = 10000)
1. linelist_cleaned %>% gtsummary::tbl_summary(include = case, statistic = case ~ 
"{n}", label = case ~ "Case") %>% add_ar(case_var = "case", 
multiplier = 10000)

I have a variables case which is boolean.

Alex thinks it is something do with this: https://github.com/R4EPI/epitabulate/blob/master/R/gt_wrappers.R#L82

amygimma commented 2 years ago

Hi Neale, sorry about that I think I did a find and replace all and typed the wrong word in. i also incidentally found an issue where if there were 0 rows in a count the functions threw an error. I am not sure how to handle this situation - for now it looks like below (see 0 to 2 year old category, in which the variable of interest is a column called "cases". Should the AR not be calculated for that age group? can AR and CI values with "-" or "NA" gtsummary ar example

amygimma commented 2 years ago

The new code that produced this table is pushed and ready to use

nsbatra commented 2 years ago

Thanks for looking into this Amy, I'll use your revised code when I dive into this next. For the table I'll defer to @aspina7, but my opinion for strata with 0 cases would to put as "-" where possible.

aspina7 commented 2 years ago

Agree - would leave counts as zero but put dashes for the rest