Hello, do you have any idea how to make that in the final tables there is a column for the n and another for the %?
For example, with this reprex:
# A tibble: 5 x 2
var1 var2
<chr> <chr>
1 A A
2 B B
3 A A
4 B B
5 A B
I use gtsummary and createtableone and in both packages the information is always in the same column separated by a space like this:
df %>%
CreateTableOne(data=.,
vars = c("var1", "var2")) %>%
print(showAllLevels = T)
Output:
level Overall
n 5
var1 (%) A 3 (60.0)
B 2 (40.0)
var2 (%) A 2 (40.0)
B 3 (60.0)
Or:
df %>%
tbl_summary()
Output:
and I would like to know how to make them in 2 different columns like this:
n | % | ||
---|---|---|---|
var1 | |||
A | 3 | 60 | |
B | 2 | 40 | |
var2 | A | 2 | 40 |
B | 3 | 60 |
How do i get this table? I export the table I get with Createtableone and I modiify it on excel so i can have the n and % in 2 columns, but I lost a lot of time doing it.