This function takes a data frame or matrix with column names and outputs an HTML table version of that data frame.

  out = NA,
  file = NA,
  note = NA,
  note.align = "l",
  anchor = NA,
  col.width = NA,
  col.align = NA,
  row.names = FALSE,
  no.escape = NA



Data set; accepts any format with column names.


Determines where the completed table is sent. Set to "browser" to open HTML file in browser using browseURL(), "viewer" to open in RStudio viewer using viewer(), if available, or "htmlreturn" to return the HTML code. Defaults to Defaults to "viewer" if RStudio is running and "browser" if it isn't.


Saves the completed variable table file to HTML with this filepath. May be combined with any value of out.


Table note to go after the last row of the table.


Alignment of table note, l, r, or c.


Character variable to be used to set an <a name> tag for the table.


Vector of page-width percentages, on 0-100 scale, overriding default column widths in HTML table. Must have a number of elements equal to the number of columns in the resulting table.


Vector of 'left', 'right', 'center', etc. to be used with the HTML table text-align attribute in each column. If you want to get tricky, you can add a ";" afterwards and keep putting in whatever CSS attributes you want. They will be applied to the whole column.


Flag determining whether or not the row names should be included in the table. Defaults to FALSE.


Vector of column indices for which special characters should not be escaped (perhaps they include markup text of their own).


This function is designed to feed HTML versions of variable tables to vtable(), sumtable(), and labeltable().

Multi-column cells are supported. Set the cell's contents to "content_MULTICOL_c_5" where "content" is the content of the cell, "c" is the cell's alignment (l, c, r), and 5 is the number of columns to span. Then fill in the cells that need to be deleted to make room with "DELETECELL".

If the first column and row begins with the text "HEADERROW", then the first row will be put above the column names.


if(interactive()) {
df <- data.frame(var1 = 1:4,var2=5:8,var3=c('A','B','C','D'),