I need to draw 3 way HTML tables with frequency and row percentages. I like gtsummary to draw 2 way HTML tables but do not know how to draw 3 way. So, I tried xtab but can't figure out how to add frequency and row-percentage in the same table. Please suggest me how to draw a nice HTML table with frequency and row percentages. Here is reproducible example.
library(vcd)
head(Arthritis) # top few observations from the data
## ID Treatment Sex Age Improved
## 1 57 Treated Male 27 Some
## 2 46 Treated Male 29 None
## 3 77 Treated Male 30 None
## 4 17 Treated Male 32 Marked
## 5 36 Treated Male 46 Marked
## 6 23 Treated Male 58 Marked
mytable <- xtabs(~ Treatment+Sex+Improved, data=Arthritis)
mytable
## , , Improved = None
##
## Sex
## Treatment Female Male
## Placebo 19 10
## Treated 6 7
##
## , , Improved = Some
##
## Sex
## Treatment Female Male
## Placebo 7 0
## Treated 5 2
##
## , , Improved = Marked
##
## Sex
## Treatment Female Male
## Placebo 6 1
## Treated 16 5
I need to add row percentage and also need to make it HTML. If I can do it with gtsummary, that's the best. But I am willing to use any other packages such as kableExtra.