Learn R Programming

hwriterPlus (version 1.0-3)

newPage: newPage

Description

Opens an HTML page/document, allowing a sequential building of an HTML page.

Usage

newPage(filename, dirname = NULL, title = filename, doctype = "\n", link.javascript = NULL, link.css = NULL, css = NULL, head = NULL, head.attributes = NULL, body.attributes = NULL)

Arguments

filename
A character string containing the filename or the path of the HTML file to be created.
dirname
An optional character string containing the path of the directory where the file should be written.
title
An optional character string containing the title of the HTML page.
doctype
A character string containing a DOCTYPE statement which declares the document type and level of HTML syntax.
link.javascript
An optional character vector containing the URL of JavaScripts to be associated with the page.
link.css
An optional character vector containing the URL of CSS stylesheets to be associated with the page.
css
An optional character vector containing inline CSS stylesheets to be associated with the page.
head
An optional character string containing an HTML fragment to be added in the section of the page.
head.attributes
An optional named list of character strings, containing the attributes.
body.attributes
An optional named list of character strings, containing the attributes.

Value

A connection which is a handle to the current HTML page.

Details

newPage opens a new file for writing and returns a page handle which is used by hwrite to append HTML elements in a current page. Any previous existing file will be overwritten.

The doctype argument is used to specify the document type and level of HTML syntax. Valid forms may be found at http://www.w3.org/QA/2002/04/valid-dtd-list.html.

link.javascript produces A

References

An invaluable source of information concerning valid HTML code and options is the website http://www.w3schools.com/.

See Also

openPage

Examples

Run this code
### The same as the example from openPage, with newPage replacing
### openPage

### Creates a new web page 'test.html' in the R temporary directory
tmpdir <- tempdir()
p <- newPage('test.html', dirname = tmpdir,
              link.css = 'http://www.ebi.ac.uk/~gpau/hwriter/hwriter.css')
hwrite('Iris example', p, center = TRUE, heading = 1)
hwrite('This famous (Fisher\'s or Anderson\'s) iris data set gives the
        measurements in centimeters of the variables sepal length and
        width and petal length and width, respectively, for 50 flowers
        from each of 3 species of iris.', p, class = 'king')
hwrite(iris, p, row.bgcolor = '#ffffaa')
closePage(p)

### Opens a web browser on the web page
if (interactive()) try(browseURL(file.path(tmpdir, 'test.html')))

Run the code above in your browser using DataLab