Recently I had the same problem when using htmlTable() (‘htmlTable’ package) and I found a simpler solution: convert the data frame to a matrix with as.matrix():
htmlTable(as.matrix(df))
And be sure that the rownames are just indices. as.matrix() conservs the same columnames. That's it.
Following the comment of @DMR, I did't notice that htmlTable()
has the parameter rnames = FALSE
for cases like this. So a better answer would be:
htmlTable(df, rnames = FALSE)