html {Hmisc} | R Documentation

## Convert an S object to HTML

### Description

`html` is a generic function, for which only two methods are currently implemented, `html.latex` and a rudimentary `html.data.frame`. The former uses the `HeVeA` LaTeX to HTML translator by Maranget to create an HTML file from a LaTeX file like the one produced by `latex`. The resulting HTML file may be displayed using a `show` or a `print` method. The browser specified in `options(browser=)` for R (`help.browser` for S-Plus) is launched to display the HTML file. `html.default` just runs `html.data.frame`.

### Usage

    html(object, ...)
    ## S3 method for class 'latex'
    html(object, file, where=c('cwd', 'tmp'),
      method=c('hevea', 'htlatex'),
      rmarkdown=FALSE, cleanup=TRUE, ...)
    ## S3 method for class 'data.frame'
    html(object,
      file=paste(first.word(deparse(substitute(object))),'html',sep='.'),
         append=FALSE, link=NULL, linkCol=1, linkType=c('href','name'), ...)
    ## Default S3 method:
    html(object,
         file=paste(first.word(deparse(substitute(object))),'html',sep='.'),
         append=FALSE, link=NULL, linkCol=1, linkType=c('href','name'), ...)
    ## S3 method for class 'html'
    print(x, ...)
    ## S3 method for class 'html'
    show(object)

### Arguments

`object` | a data frame or an object created by `latex`. For `show` is an object created by `html`. For the generic `html` is any object for which an `html` method exists.
`file` | name of the file to create. The default file name is `object.html` where `object` is the first word in the name of the argument for `object`. For `html.latex` specify `file=''` or `file=character(0)` to print html code to the console, as when using `knitr`.
`where` | for `html`. Default is to put output files in current working directory. Specify `where='tmp'` to put in a system temporary directory area.
`method` | default is to use system command `hevea` to convert from LaTeX to html. Specify`method='htlatex'` to use system command `htlatex`, assuming the system package `TeX4ht` is installed.
`rmarkdown` | set to `TRUE` if using RMarkdown (usually under `knitr` and RStudio). This causes html to be packaged for RMarkdown and output to go into the console stream. `file` is ignored when `rmarkdown=TRUE`.
`cleanup` | if using `method='htlatex'` set to `FALSE` if `where='cwd'` to prevent deletion of auxiliary files created by `htlatex` that are not needed when using the final `html` document (only the `.css` file is needed in addition to `.html`). If using `method='hevea'`, `cleanup=TRUE` causes deletion of the generated `.haux` file.
`append` | set to `TRUE` to append to an existing file
`link` | character vector specifying hyperlink names to attach to selected elements of the matrix or data frame. No hyperlinks are used if `link` is omitted or for elements of `link` that are `""`. To allow multiple links per link, `link` may also be a character matrix shaped as `object` in which case `linkCol` is ignored.
`linkCol` | column number of `object` to which hyperlinks are attached. Defaults to first column.
`linkType` | defaults to `"href"`
`...` | ignored
`x` | an object created by `html`

### Side Effects

`print` or `show` launch a browser

### Author(s)

Frank E. Harrell, Jr.
Department of Biostatistics,
Vanderbilt University,
f.harrell@vanderbilt.edu

### References

Maranget, Luc. HeVeA: a LaTeX to HTML translater. URL: http://para.inria.fr/~maranget/hevea/

### See Also

`latex`

### Examples

    ## Not run:
    x <- matrix(1:6, nrow=2, dimnames=list(c('a','b'),c('c','d','e')))
    w <- latex(x)
    h <- html(w) # run HeVeA to convert .tex to .html
    h <- html(x) # convert x directly to html
    h            # launch html browser by running print.html
    w <- html(x, link=c('','B'))   # hyperlink first row first col to B

    # Assuming system package tex4ht is installed, easily convert advanced
    # LaTeX tables to html
    getHdata(pbc)
    s <- summaryM(bili + albumin + stage + protime + sex + age + spiders ~ drug,
                  data=pbc, test=TRUE)
    w <- latex(s, npct='slash', file='s.tex')
    z <- html(w)
    browseURL(z$file)

    d <- describe(pbc)
    w <- latex(d, file='d.tex')
    z <- html(w)
    browseURL(z$file)

    ## End(Not run)

[Package Hmisc version 3.17-3 Index]