1\name{HTML.data.frame} 2\alias{HTML.data.frame} 3\alias{HTML.matrix} 4\title{Write a data.frame (or matrix) to a HTML output} 5\description{ 6 This function exports a data.frame to a HTML file. Many arguments allow to customize the layout of the HTML table. 7} 8 9\usage{\method{HTML}{data.frame}(x, file = HTMLGetFile(), 10 Border = 1, innerBorder = 0, classfirstline = "firstline", 11 classfirstcolumn = "firstcolumn", classcellinside = "cellinside", 12 append = TRUE, align = "center", caption = "", captionalign = "bottom", 13 classcaption = "captiondataframe", classtable = "dataframe", 14 digits = getOption("R2HTML.format.digits"), 15 nsmall = getOption("R2HTML.format.nsmall"), 16 big.mark = getOption("R2HTML.format.big.mark"), 17 big.interval = getOption("R2HTML.format.big.interval"), 18 decimal.mark = getOption("R2HTML.format.decimal.mark"), 19 sortableDF = getOption("R2HTML.sortableDF"), row.names = TRUE, ...) 20} 21 22\arguments{ 23 \item{x}{ a data.frame} 24 \item{file}{ target HTLM output} 25 \item{Border}{ the size of the border around the table. Could be 0,1,... but also NULL} 26 \item{innerBorder}{ the size of the border inside the table - see details} 27 \item{classfirstline}{ CSS class for the first line (header - variable names) } 28 \item{classfirstcolumn}{ CSS class for the first column (rownames)} 29 \item{classcellinside}{ CSS class for others cells} 30 \item{append}{ logical. If 'TRUE' output will be appended to 'file'; otherwise, it will overwrite the contents of 'file'} 31 \item{align}{ alignment to be used: center, left or right} 32 \item{caption}{ optional caption to append to the table } 33 \item{captionalign}{ alignment to be used for the caption: could be bottom or top} 34 \item{classcaption}{ CSS class to use for caption} 35 \item{classtable}{ CSS class to be used for the whole table (in html <table> statement)} 36 \item{digits}{ number of digits to use for rounding} 37 \item{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'} 38 \item{big.mark}{ character; if not empty used as mark between every 'big.interval' decimals before (hence 'big') the decimal point} 39 \item{big.interval}{ see 'big.mark' above; defaults to 3} 40 \item{decimal.mark}{the character used to indicate the numeric decimal point} 41 \item{sortableDF}{See details} 42 \item{row.names}{ logical. If 'TRUE' row.names are shown in the output; otherwise they are omitted} 43 \item{\dots}{ ...} 44} 45\details{ 46 For the moment, \code{HTML.matrix} and \code{HTML.data.frame} do have the same options. 47 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 recommended to rely on CSS to obtain such results... 48 49 Now \code{format} is called to format numerical values (modif. suggested by Arne Henningsen). The corresponding arguments are: \code{digits}, \code{nsmall}, \code{big.mark}, \code{big.intervall} and \code{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). 50 51 52 Some options are used to pass default values. 53 You can see those options with (by example): 54 \code{getOption("R2HTML.format.decimal.mark")} and {options("R2HTML.format.decimal.mark"=",")} 55 56 Sortable data.frame uses a DHTML behavior. This requires the file \file{tablesort.htc} which comes with \pkg{R2HTML} 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). 57 58 59} 60\value{ 61 no value returned. 62} 63 64\author{ Eric Lecoutre} 65 66 67 68 69\seealso{ \code{\link{HTML}}} 70\examples{ 71tmpfic=HTMLInitFile(tempdir(),CSSFile=system.file("samples", "R2HTML.css", package="R2HTML")) 72data(iris) 73HTML(as.title("Fisher Iris dataset"),file=tmpfic) 74HTML(iris, file=tmpfic) 75# File is generated, you can call the browser: 76\dontrun{browseURL(tmpfic)} 77 78# Export one line of iris using default decimal separator 79HTML(iris[1,],file="") 80 81# Seeing default decimal separator: 82getOption("R2HTML.format.decimal.mark") 83 84# Modifying it: 85options("R2HTML.format.decimal.mark"=",") 86HTML(iris[1,],file="") 87 88# Bypassing value set in option: 89HTML(iris[1,],file="",decimal.mark="*") 90 91# Using a vector for formatting options 92HTML(iris[1:2,1:2],nsmall=c(3,1),file="") 93} 94\keyword{datasets} 95\keyword{IO} 96