We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Working on the r4epis sitrep package and need these two functions in epitabulate but they're not working.
add_ar
The function builds on a tbl_summary output, which works fine:
But then when you add on the add_ar function it looks like this:
See here:
library(dplyr) library(gtsummary) library(epitabulate) # Create dummy data linelist_cleaned <- data.frame( age_group = sample(c("0-4", "5-9", "10-14", "15-19"), 20, replace = TRUE) ) population_data_age <- data.frame( age_group = c("0-4", "5-9", "10-14", "15-19"), population = c(5000, 6000, 5500, 5200) # Dummy population counts ) # Test the code linelist_cleaned %>% mutate(case_total = TRUE) %>% select(case_total, age_group) %>% gtsummary::tbl_summary( include = age_group, label = list(age_group ~ "Age Group") ) %>% epitabulate::add_ar( ## specify which variable counts cases (dummy) case_var = "case_total", ## get the population counts as a vector population = pull(population_data_age, population), drop_tblsummary_stat = TRUE)
My solution was to use attack_rate instead:
attack_rate
linelist_cleaned |> count(age_group) |> left_join(population_data_age) |> mutate(attack_rate_result = pmap(list(n, population), ~ attack_rate(.x, .y, multiplier = 10000))) |> select(-n, -population) |> unnest(attack_rate_result)
add_cfr()
This function also builds on a tbl_summary() output, which itself is fine, but then add_cfr() makes the output blank. You can see here:
library(dplyr) library(gtsummary) library(epitabulate) # Dummy data linelist_cleaned <- data.frame( patient_facility_type = sample(c("Inpatient", "Outpatient"), 20, replace = TRUE), DIED = sample(c(TRUE, FALSE, NA), 20, replace = TRUE), case_def = sample(c("Confirmed", "Probable", "Suspected"), 20, replace = TRUE) ) # Test the code linelist_cleaned %>% filter(patient_facility_type == "Inpatient") %>% select(DIED, case_def) %>% gtsummary::tbl_summary( include = case_def, statistic = case_def ~ "{n}", missing = "no", label = case_def ~ "Case definition" ) %>% modify_header(stat_0 = "Cases (N)") |> # Use wrapper function to calculate cfr add_cfr(deaths_var = "DIED")
The text was updated successfully, but these errors were encountered:
aspina7
No branches or pull requests
Working on the r4epis sitrep package and need these two functions in epitabulate but they're not working.
add_ar
The function builds on a tbl_summary output, which works fine:
But then when you add on the add_ar function it looks like this:
See here:
My solution was to use
attack_rate
instead:add_cfr()
This function also builds on a tbl_summary() output, which itself is fine, but then add_cfr() makes the output blank. You can see here:
The text was updated successfully, but these errors were encountered: