Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gt_mr missing? #22

Open
nsbatra opened this issue Jun 10, 2022 · 4 comments
Open

gt_mr missing? #22

nsbatra opened this issue Jun 10, 2022 · 4 comments

Comments

@nsbatra
Copy link

nsbatra commented Jun 10, 2022

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
Copy link
Contributor

amygimma commented Jun 10, 2022

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
Copy link
Contributor

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

@nsbatra
Copy link
Author

nsbatra commented Jun 14, 2022

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
Copy link
Member

aspina7 commented Jun 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants