I am working on making a baseline characteristic table for a study and I am wondering if there is a way to show the percent of patients in which a baseline demographic occurs? I can make a table and then calculate in r as a separate code but there has to be a way to automate it so that the percentage of the total shows up when I run the code (ex: 2/20 patients have diabetes at baseline - I want to display that the value is 10%).
Thanks in advance for your help!
table(v1, v2)
#See result of table and then do the math in R
2/20
My ideal table would look like this:
diabetes y diabetes n
drug x 1 (10%) 9 (90%)