Last data update: 2014.03.03

R: Write a correlation matrix with HTML formatting
HTML.cormatR Documentation

Write a correlation matrix with HTML formatting

Description

Although the class ‘cormat’ is not defined, the function is called HTML.cormat, to highlight the fact it should be called only with a correlation matrix. It is documented as a regular S3 method for technical reasons. Contrary to the signature shown, below, you will call it as HTML.cormat, explicitly, as shown in the examples.

Usage

## S3 method for class 'cormat'
HTML(x, file = HTMLGetFile(),
digits = 2, append = TRUE, align = "center",
caption = "", captionalign = "bottom",
classcaption = "captiondataframe", classtable = "cormat", useCSS = TRUE, ...)

Arguments

x

a correlation matrix

file

target HTLM output

digits

number of digits to use for rounding

append

logical. If 'TRUE' output will be appended to 'file'; otherwise, it will overwrite the contents of 'file'

align

alignment to be used: center, left or right

caption

optional caption to append to the table

captionalign

alignment to be used for the caption: could be bottom or top

classcaption

CSS class to use for caption

classtable

CSS class to be used for the whole table (in html <table> statement)

useCSS

whether to use CSS or not for traffic highlighting

...

...

Value

returns (invisibly) the input

Note

“Highlighting traffic” is a simple technique which allows to have a visual representation of data. It is particularly well suited for correlation matrices in order to have at a glance the underlying (linear) structure of data. If your output doesn't rely on CSS styles, you should use useCSS=FALSE option, whihc hard codes grey levels for correlations.

For CSS uses, you can (re)define colours and other attributes for correlations in seq(0,1,length=11)-defined intervals. Some definitions could be equivalent, not showing any difference. You can, by example, redefine CSS so that only correlations greater than 0.9 are showned, and lower the size of cells, which could be usefull for veryu big datasets.

Author(s)

Eric Lecoutre

See Also

HTML

Examples

	tmpfic=HTMLInitFile(tempdir(),CSSFile="http://www.stat.ucl.ac.be/R2HTML/Pastel.css")
	data(iris)
	HTML(as.title("Fisher Iris dataset / Correlation matrix - normal matrix"),
	     file=tmpfic)
	HTML(cor(iris[,1:4]), file=tmpfic)
	HTML(as.title("Fisher Iris dataset / Correlation matrix - traffic highlighting"),
	     file=tmpfic)
	HTML.cormat(cor(iris[,1:4]), file=tmpfic)

	# File is generated, you can call the browser:
	## Not run: browseURL(tmpfic)
	

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(R2HTML)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/R2HTML/HTML.cormat.Rd_%03d_medium.png", width=480, height=480)
> ### Name: HTML.cormat
> ### Title: Write a correlation matrix with HTML formatting
> ### Aliases: HTML.cormat
> ### Keywords: IO multivariate
> 
> ### ** Examples
> 
> 	tmpfic=HTMLInitFile(tempdir(),CSSFile="http://www.stat.ucl.ac.be/R2HTML/Pastel.css")
> 	data(iris)
> 	HTML(as.title("Fisher Iris dataset / Correlation matrix - normal matrix"),
+ 	     file=tmpfic)
> 	HTML(cor(iris[,1:4]), file=tmpfic)
> 	HTML(as.title("Fisher Iris dataset / Correlation matrix - traffic highlighting"),
+ 	     file=tmpfic)
> 	HTML.cormat(cor(iris[,1:4]), file=tmpfic)
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length         1.00       -0.12         0.87        0.82
Sepal.Width         -0.12        1.00        -0.43       -0.37
Petal.Length         0.87       -0.43         1.00        0.96
Petal.Width          0.82       -0.37         0.96        1.00
> 
> 	# File is generated, you can call the browser:
> 	## Not run: browseURL(tmpfic)
> 	
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>