Basic 2x2 tables and stratified analysis in R

Hello! I learned field epi starting with Excel, Epi Info, and Stata. With Epi Info and Stata in particular, it is quite easy to teach the basics of calculating OR/RR and showing 2x2 tables. For example, in Epi Info you can use the visual dashboard or in Stata you can simply do cc casestatus riskfactor to show a 2x2 table with CI and p-value calculations. To do a stratified analysis, you can do cc casestatus riskfactor, by(confounder). In R, it seems much less straightforward. Is there a package where you can do something like linelist %>% cc(casestatus, riskfactor) to produce something similar?

Though this can be done relatively quickly with tbl_uvregression() with multiple risk factors, I find that showing 2x2 tables is much more visual and intuitive when teaching about case-control and cohort studies for the first time. Iā€™m trying to see how R can be incorporated as early as possible into the FETP curriculum like merging it with the topics on epidemiologic study designs and biostatistics.

No specific dataset here but I just want to spin this off from the other discussion on calculating RR/OR in gtsummary.

hey ian - you are right there is currently nothing that works very easily for stratified tables, but we are working on a gtsummary wrapper function in the epitabulate package!
This might still be a while before its done and on CRAN though.
There is already the tab_univariate() function in that package which allows stratified (but only with TRUE/FALSE vars) - and this function is going to be retired once the other one is complete.
The other alternative is the epiR package - but here too you need to produce a table in advance which is 0/1.
Will let you know when function works properly!

1 Like

Dear Alex,

Thank you for your response. Looking forward to the additional functions. An easy-to-use function that replicates stata or epi info 2x2 tables for crude RR/OR is helpful for teaching the basics of epi and will allow the use of R earlier in the training process.


1 Like