I want to use 2 times the digits= argument in tbl_summary but I can't.
Once it would be like this to specify the number of decimal digits
digits = list(all_categorical() ~ c(0,1))
and the second one to indicate that there is no space as a separator for big numbers
digits = ~label_style_number(big.mark = "")
But it doesn't work in the same code
df %>% %>%
mutate_all(as.factor) %>%
tbl_summary(statistic = list(all_categorical() ~ "{n} ({p})"),
digits = list(all_categorical() ~ c(0,1)),
digits = list(a ~ label_style_number(big.mark = "")))
Error in tbl_summary(., statistic = list(all_categorical() ~ “{n} ({p}”), :
formal argument “digits” matches multiple specified arguments.
also tried this
df %>%
mutate_all(as.factor) %>%
tbl_summary(
by= a,
missing = "always",
statistic = list(all_categorical() ~ "{n} ({p})"),
sort = all_categorical(FALSE) ~ "frequency",
digits = list(all_categorical() ~ c(0, 1),
b ~ label_style_number(big.mark = "")))
but it returns a 0 in the decimals for all values
How can I have both things?
This is the minimal reproducible example I use:
df<-
tibble(a= sample(c('red', 'blue', 'pink'),
size= 10000,
replace= T),
b= sample(c('car', 'bike', 'boat'),
size= 10000,
replace= T))