This is similar to print.tabular, but it inserts the code to
display the table in an HTML table.
Usage
## S3 method for class 'tabular'
html(object, file="", options=NULL, id=NULL, ...)
Arguments
object
The tabular object.
file
A filename to which to write the HTML code.
options
A list of options to set for the duration of the call.
id
A unique identifier to set for this table and the associated
CSS style, or NULL, for no id.
...
Settings for default formatting. See Details below.
Details
The html() method produces HTML output suitable for inclusion in an HTML page.
In HTML, it is mainly the CSS style sheet that determines the look of the table.
When formatting a table, html.tabular sets the CSS class according to the
table's Justify setting; justifications of c("l", "c", "r") are
translated to classes c("left", "center", "right") respectively; other strings
will be passed through and used directly as class names.
If the id value is not NULL, then it will be used
as the CSS id selector when searching for a style.
See table_options for a number of options that control formatting, including
the default style sheet.
Value
The html() method writes the HTML code to file and returns a list containing
that name, with class "html".
See Also
print.tabular, latex.tabular, html, htmloptions
Examples
X <- rnorm(125, sd=100)
Group <- factor(sample(letters[1:5], 125, rep=TRUE))
tab <- tabular( Group ~ (N=1)+Format(digits=2)*X*((Mean=mean) + Heading("Std Dev")*sd) )
save <- table_options()
table_options(rowlabeljustification="c")
f <- tempfile(fileext=".html")
con <- file(f, "wt")
html(tab, con, options=htmloptions(head=TRUE, table=FALSE))
writeLines("<p>This table has pad = FALSE. The centered numbers look
sloppy.<br>", con)
html(tab, con, options=htmloptions(head=FALSE, table=TRUE, pad=FALSE))
writeLines("<p>This table has pad = FALSE and justification="r".
The justification makes the columns of numbers look all right (except
for the hyphens used as minus signs), but they are placed poorly
relative to the labels.<br>", con)
html(tab, con, options=htmloptions(head=FALSE, table=TRUE, pad=FALSE, justification="r"))
writeLines("<p>This one has pad = TRUE. It looks best, but if you cut
and paste, the spacing characters may cause problems.<br>", con)
html(tab, con, options=htmloptions(head=FALSE, table=TRUE, pad=TRUE))
table_options(save)
close(con)
browseURL(f)