One default I frequently correct is treatment of discrete numeric values. Pay attention to the footnote on the statistical tests performed and adjust if needed with the test argument in the add_p function. In addition, gtsummary makes an educated guess on how to summarize your data and which statistical test to use. Statistical tests performed: Wilcoxon rank-sum test chi-square test of independence Statistics presented: Mean (SD) % (n / N) Note that there is an overall N that corresponds to the number of observations, and each each variable can have its own N that corresponds to the number of non-missing observations for that variable. Here are a few modifications you might be interested in trying to customize your table, including adding an overall column, custom statistic formatting, and table styling. Statistics presented: Median (IQR) n (%)Īnd wait - did you see that?! The raw data had variable names of q12, stheight, and q69 but the table printed the variable label! (I previously tweeted about the awesome package pairing of haven and gtsummary.) If your data does not come with handy labels, you can create them with the label option in tbl_summary or with the var_label function in the labelled package. I’ll demonstrate with the Youth Risk Behavior Surveillance System (YRBSS) data my previous post Leveraging labelled data in R has more background details. My favourite R package for: summarising data by Dabbling with data (2018) How to make beautiful tables in R by R for the Rest of Us (2019). If you are still searching for your favorite table package, here are two round up resources: The gtsummary documentation is excellent so I won’t cover all of its awesome functionality, but I will add a bit of my specific experience. This blog post is to promote gtsummary and make it more searchable for those still seeking the one table to rule them all. When I showed him gtsummary in 5 minutes, his reaction was all Try it out! BackgroundĪ colleague learning R just told me that he spent 45 minutes searching for a summary table function and couldn’t quite find anything that met his needs. The gtsummary package in R creates amazing publication / presentation / whatever-you-need-it-for ready tables of summary statistics. Figure 1: Happy R adapted from artwork by the beach and cocktail images are from ,
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |