Export to HTML tables {GCDkit}R Documentation

Exporting data or results to HTML tables

Description

Outputs the specified data with (optional) labels into HTML. This format is useful for importing into spreadsheets, word processors or publishing on the WWW.

Usage

    HTMLTableMain(what, digits=2, desc=NULL, title=" ", sum.up=FALSE,
    open=TRUE, close=TRUE, browse=TRUE, 
    filename=paste(data.dir,"R2HTML/htmltable",sep="/"),
    rotate=FALSE)

    HTMLtableOrdered(what, which=rownames(what), labs=labels, digits=2, 
    desc=NULL, title=" ", sum.up=FALSE, key1=NULL, key1descending=FALSE, 
    key2=NULL, filename=paste(data.dir,"R2HTML/htmltable",sep="/"), 
    split.by=25, rotate=TRUE) 

    HTMLTableWR(filename="htmltable")
    
    HTMLTableWR.Jupyter(digits=3, desc=NULL, title=" ", sum.up=TRUE,
    rotate=FALSE)

    HTMLTableResults(filename="htmltable")
    
    HTMLTableResults.Jupyter(digits=3, desc=NULL, title=" ", sum.up=TRUE,
    rotate=FALSE)

Arguments

what

numeric matrix; data to be exported

digits

required precision

desc

name of the columns within 'labels' to be attached to the table

title

main title

sum.up

logical; should be a sum calculated?

open

logical; should be opened a new HTML file?

close

logical; should be the HTML file closed when finished?

browse

logical; should be the HTML file finally opened in the default browser?

filename

optional name for the file produced

rotate

logical, should be the table transposed, with samples in columns and variables in rows?

which

(optional) sample names in numeric matrix 'what' for the output

labs

name of variable with textual labels

key1

is a variable in numeric matrix 'what'

key1descending

logical; should be the 'key1' sorted in a descending order?

key2

is a grouping information (name of a column in 'labs' or a character vector)

split.by

maximal number of data columns per page

Details

HTMLTableWR and HTMLTableResults are GUI front ends to HTMLTableMain, the former enabling the user to choose samples (rows) and columns for the output using the searching mechanisms common in the GCDkit.

HTMLTableWR outputs the numeric data (with optional labels and sum) stored in the data matrix 'WR'. The function HTMLTableWR.Jupyter provides the same functionality for Jupyter notebooks.

HTMLtableOrdered also outputs the numeric data stored in the numeric matrix specified by parameter 'what'. Optional argument 'which' gives the list of sample names (rows) in the matrix to be saved. The data are first sorted based on 'key2', which typically gives a grouping information (name of a column in 'labs'). Within each of the groups, the data are further sorted based on the numeric variable 'key1'. See example.

HTMLTableResults outputs the results of the most recent calculation (with optional labels and sum) as stored in the variable 'results'. The function HTMLTableResults.Jupyter provides the same functionality for Jupyter notebooks.

This function attempts to format sub- and superscripts in the names of variables.

The created file 'filename' is placed in the system temporary folder; when finished, it is previewed in a browser. The appearance for the table is determined by the cascade style file R2HTML.css in the GCDkit main subdirectory.

htmltable.png

Value

None.

Warning

All these functions require the 'R2HTML' library. It must be downloaded from the CRAN and properly installed. Their presence is checked before the code is executed.

Jupyter versions of the functions HTMLTableWR.Jupyter and HTMLTableResults.Jupyter require a correctly configured IR kernel connection, including the 'IRdisplay' library.

Author(s)

The R2HTML package was written by Eric Lecoutre.

The IRdisplay package was written by Thomas Kluyver, Philipp Angerer and Jan Schulz.

Vojtěch Janoušek, vojtech.janousek@geology.cz

Examples

    sampleDataset("sazava")

    HTMLTableMain(WR[,c("SiO2","MgO","FeOt")],digits=2,desc="Suite",
        title="Sazava [wt.%]")

    HTMLtableOrdered(WR[,LILE],digits=1,key1="SiO2",key2="Suite",
        title="Large Ion Lithophile Elements (ppm)",split.by=3)

[Package GCDkit version 6.2.0 Index]