hwrite {hwriter}R Documentation

HTML writer

Description

Outputs an R object in HTML format.

Usage

hwrite(x, page=NULL, ...)

Arguments

x an R object to output in HTML format. Objects of type character, vector, matrix and data.frame are currently supported.
page an optional connection, a character string naming the file to write to or a page object returned by openPage.
... optional arguments depending on the type of x. See Details.

Details

Depending on its type and its length, x is written as a character string, a character vector or as an HTML table.

Many optional arguments can be used to render an R object. Arguments are listed below and rendering examples are shown in Examples.

Following optional arguments can be always used, independently of the type of x:

br
a logical specifying if a breakline (carriage return) should be appended at the end of x. Default is FALSE.
center
a logical indicating if x should be centered. Default is FALSE.

Value

A character string containing the output HTML code.

Additional arguments for text elements

If x is a vector of only one element, it will be written as a character string. Following optional arguments can be used:

heading
a numeric containing the heading level style. Valid values spans from 1 to 5. See Examples.
link
a character string containing an URL the HTML output text will point to. This argument is the HTML equivalent of <a>.
style
a character string containing the CSS inline style to be used to render the object. This versatile argument allows to change the font properties (typeface, bold, italic, size, color), margins, alignement, spacing, padding. See Examples.

Additional arguments for vectors

If x is a vector with more than one element, it will be written as an HTML table by default unless table is set to FALSE, for which it will be written as a vector of character strings. Optional specific arguments to either character strings or HTML tables can be used, together with the following ones:

table
If TRUE, the vector is written as an HTML table with one row and a number of columns equals to the number of elements in x. If FALSE, the vector is written as a character vector. Default is TRUE.
dim
a couple of numeric values indicating the desired number of rows and columns in the table. Can be used only if table is TRUE.
byrow
logical. If FALSE the table is filled by columns, otherwise the table is filled by rows. Can be used only if table is TRUE. Default is FALSE.
names
a logical indicating if the names of the elements should be written if the vector is named. Default is TRUE.

Additional arguments for tables

If x is a matrix or a data.frame, x is written as an HTML table. Following optional arguments can be used:

border
a numeric. Specifies the table border width. A value of 0 implies that no borders will be drawn. Default border styles are not really pretty. Use 'style' instead to have a finer control on borders.
row.names, col.names
a logical value indicating whether the row (resp. columns) names of x are to be written. Default is TRUE.
bgcolor
a character string or a character matrix. Specifies the cell background colors, in HTML color format (hexadecimal or color names). If bgcolor is a character string, the whole table will be painted with this color. If bgcolor is a character matrix of the same size as x which contains the cell colors, cells will be painted accordingly to the matrix. A matrix can contain NAs when cells don't have a background color. The matrix may contain one extra row and/or column to target the heading (row.names, col.names) table cells. See Examples.
row.bgcolor, col.bgcolor
a list of named character vectors. This argument may contain a list of named vectors of colors pointing the corresponding rows (resp. columns) names of x. If sizes don't match, values are recycled using R style. Unnamed vector of colors will point the heading rows (resp. columns). See Examples.
style, row.style, col.style
These arguments follows the same rules as bgcolor, row.bgcolor and col.bgcolor but define CSS styles that should be used to render table cells. CSS styles are very versatile and allow to change border style, typeface, font properties, align, boldness, font color, italic... See Examples.
link, row.link, col.link
These arguments follows the same rules as bgcolor, row.bgcolor and col.bgcolor but define here URLs that the cells will point to. See Examples.
cellspacing, cellpadding
a numeric. Defines the HTML cell spacing and HTML cell pading settings of the table. See Examples.
width
a character string. Specifies the global table width in HTML units (pixels or %).
col.width
a named character vector. Specifies the columns width in HTML units (pixels or %) where names of col.width are used to point column names of x. NAs may be used to let some column widths unspecified.

See Examples for many illustrated examples of all arguments.

Author(s)

Gregoire Pau, gpau@ebi.ac.uk, 2008

See Also

openPage, closePage, hwriteImage, hmakeTag.

Examples

 hwriter:::writeExample()

[Package hwriter version 0.91 Index]