{R2HTML}R Documentation

Write a data.frame (or matrix) to a HTML output


This function exports a data.frame to a HTML file. Many arguments allow to customize the layout of the HTML table.

Usage, file = .HTML.file, Border = 1, innerBorder=0,classfirstline = "firstline",\cr 
classfirstcolumn = "firstcolumn", classcellinside = "cellinside", \cr
append = TRUE, align = "center", caption = "", captionalign = "bottom", \cr
classcaption = "captiondataframe", classtable = "dataframe", \cr
digits=2,nsmall = 0, big.mark = "", big.interval = 3, decimal.mark = ",",sortableDF=FALSE, ...),file=)


x a data.frame
file target HTLM output
Border the size of the border around the table. Could be 0,1,... but also NULL
innerBorder the size of the border inside the table - see details
classfirstline CSS class for the first line (header - variable names)
classfirstcolumn CSS class for the first column (rownames)
classcellinside CSS class for others cells
append logical. If 'TRUE' output will be appended to 'file'; otherwise, it will overwrite the contents of 'file'
align alignment to be used: center, left or right
caption optional caption to append to the table
captionalign alignment to be used for the caption: could be bottom or top
classcaption CSS class to use for caption
classtable CSS class to be used for the whole table (in html <table> statement)
digits number of digits to use for rounding
nsmall number of digits which will always appear to the right of the decimal point in formatting real/complex numbers in non-scientific formats. Allowed values '0 <= nsmall <= 20'
big.mark character; if not empty used as mark between every 'big.interval' decimals before (hence 'big') the decimal point
big.interval see 'big.mark' above; defaults to 3
decimal.mark the character used to indicate the numeric decimal point
sortableDF See details
... ...


For the moment, HTML.matrix and do have the same options. Tables are build using two different HTML tables, one beeing encapsulated within the other, which allows to have a table without borders inside but with a border outside. It is nevertheless recommanded to rely on CSS to obtain such results...

Now format is called to format numerical values (modif. suggested by Arne Henningsen). The corresponding arguments are: digits, nsmall, big.mark, big.intervall and decimal.mark. For each argument, one can supply either a single value or a vector. In the second case, the size of the vector has to be the number of columns of the data.frame and formatting options will be used element-wise (column by column).

Some options are used to pass default values. You can see those options with (by example): getOption("R2HTML.format.decimal.mark") and {options("R2HTML.format.decimal.mark"=",")}

Sortable data.frame uses a DHTML behavior, as explained and showned in This requires the file ‘’ which comes with R2THML to be placed in the same directory than the output. This functionality only works for HTML files located on a web server (not on local computer).


no value returned.


Eric Lecoutre

See Also



HTML(as.title("Fisher Iris dataset"),file=tmpfic)
HTML(iris, file=tmpfic)
# File is generated, you can call the browser:
## Not run: browseURL(tmpfic)

# Export one line of iris using default decimal separator

# Seeing default decimal separator:

# Modifying it:

# Bypassing value set in option:

# Using a vector for formatting options

[Package R2HTML version 1.4-3 Index]