Reputation: 45
I would like to obtain 3 decimals for continuous variables outputs in gtsummary for both mean and SD. In the default setting it exports 2 decimals; in a prior post there is a way to change the percentage in categorical variables to 1 decimal
# set theme where percentages are rounded to 1 decimal place
set_gtsummary_theme(list(
"tbl_summary-fn:percent_fun" = function(x) sprintf(x * 100, fmt='%#.1f')
))
Is there a way to change it for Mean and SD for continuous variables?
Thanks!
#gtsummary
Upvotes: 1
Views: 1584
Reputation: 11774
The default number of decimal places for continuous variables to be rounded isn't 2 decimal places. The number of decimal places is determined by the spread of the data, e.g. variables with large spread may be rounded to the nearest integer, and variables with a small spread may be rounded to 2 or 3 decimal places. Unfortunately, there is no way to change the default globally. You'll need to use the tbl_summary(digits=)
argument to change number of decimal places a variable's summary statistics are rounded to.
Upvotes: 1