Ok, I've found one option that does work well with R markdown and that is using the psych::describe
command. This has the advantage that the final table is a data.frame
object that can then be further manipulated.
with xtable
library(psych)
library(xtable)
table.desc <- describe(mytable)
print(xtable(table.desc), type="html")
or using Gmisc
library(psych)
table.desc <- describe(mytable)
table.prep <- as.matrix(table.desc)
library(Gmisc)
htmlTable(table.prep)
Please note that in this example you do want to include the rownames, as they are part of the describe
output. Also Gmisc
inherits the Hmisc::describe
command and has thus to be loaded AFTER creating the stats table.