0

I'm using tableone to create summary tables. Some of my data is categorical, some is continuous that requires mean/sd or median/IQR depending on the variable. While the output I get is technically correct, it is pretty ugly looking and doesn't print into rmarkdown well. I had previously used table1 which looked better, but didn't give me mean/sd vs median/IQR like I needed.

My inputs: full_baseline_variables is a character vector with all the column names I need. Class is a variable in outcomes that defines each of my subgroups. Outcomes is a dataframe full_categorical_baseline is a character vector with the subset of variables that are categorical.

     tab1 <- CreateTableOne(vars = full_baseline_variables, strata = "Class", data = outcomes, factorVars = full_categorical_baseline)

If I just print the above, it prints everything as mean/sd. I need a few variables as median/IQR, so I've created an additional character vector to put into the print function.

     table1 <- print(tab1, nonnormal = full_medians_baseline)

The output I get is correct but is hard to read. Does anyone have suggestions of how to take the tab1 output and make a nicer table than with the print function?

BethG92
  • 3
  • 2
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. What makes a "nicer table" is very subjective. Please be specific about what the output requirements are. – MrFlick Jun 08 '23 at 15:57
  • I would recommend using other tabling packages, such as gtsummary – Mike Jun 08 '23 at 16:50

0 Answers0