Calculate risk ratios from line-list data
nice_rr(n1, d1, n2, d2)
numerator for the reference group
denominator for the reference group
numerator for the comparator group
denominator for the comparator group
data(smokers)
lc_agg <- smokers %>%
dplyr::group_by(smoker) %>%
dplyr::summarise(denominator = dplyr::n(), numerator = sum(lung_cancer)) %>%
tidyr::pivot_wider(names_from = smoker, values_from = c(denominator, numerator))
lc_agg
#> # A tibble: 1 x 4
#> denominator_0 denominator_1 numerator_0 numerator_1
#> <int> <int> <int> <int>
#> 1 60000 30000 6 39
nice_rr(n1 = lc_agg$numerator_0, d1 = lc_agg$denominator_0,
n2 = lc_agg$numerator_1, d2 = lc_agg$denominator_1)
#> rr se_log_rr lci uci
#> 1 13 0.438472 5.504381 30.70282