taf2html {TAF}R Documentation

Convert TAF Table to HTML

Description

Convert a TAF table to HTML code and optionally write to a file.

Usage

taf2html(x, file = "", align = "", header = align,
  digits = getOption("digits"), center = "style=\"text-align:center\"",
  left = "style=\"text-align:left\"",
  right = "style=\"text-align:right\"", append = FALSE)

Arguments

x

a data frame in TAF format.

file

a filename, or special values NULL or "".

align

a string (or a vector of strings) specifying alignment of data cells.

header

a string (or a vector strings) specifying alignment of header cells.

digits

significant digits for numeric columns.

center

HTML attribute to indicate center alignment.

left

HTML attribute to indicate left alignment.

right

HTML attribute to indicate right alignment.

append

whether to append to an existing file.

Details

The align argument can be a vector of strings to specify column-specific alignment, for example c("l","r","l","l"). Only the first letter (case-insensitive) is used, so "left" is equivalent to "L". An empty string (the default), or any string that does not begin with C, L, or R indicates no specific alignment.

The header argument can be used to specify an alignment for the column names that is different from the data values. The default is to use the same alignment as the data values.

The center, left, and right arguments can be used to specify the exact HTML attribute to render alignment, for users who are familiar with cascading style sheets (CSS). For example, the long-winded style="text-align:center" could be shortened to class="L" if a corresponding class has been defined in CSS.

Instead of using file to pass a filename, it can have the special value file = NULL to return the HTML code as a vector of strings or file = "" (the default) to show the HTML in the console.

Value

NULL, or a vector of strings if file = NULL.

Note

The resulting HTML conforms to the HTML5 standard and aims for compact output, omitting optional closing tags and rendering each row of data as one row of HTML code.

See Also

write.taf writes a TAF table to a file.

TAF-package gives an overview of the package.

Examples

taf2html(catage.taf)
taf2html(catage.taf, align=c("L","R","R","R","R"))

## Not run: 
taf2html(catage.taf, "catage.html")
taf2html(catage.taf, "catage.html", align=c("L","R","R","R","R"),
         append=TRUE)

## End(Not run)


[Package TAF version 4.2.0 Index]