icorr: icorr

Description Usage Arguments Details See Also Examples

View source: R/iplots.R

Description

Interactive correlation matrices (heat maps) with optional scatter plots.

Variables will be clustered (see details) and reordered by default. Cells will be labeled with the column names of the input data, and if a scatter plot is created, points will be labeled with the row names (this can be over-ridden by using the labels parameter).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
icorr(
  mat,
  group,
  col,
  labels = NULL,
  cluster = TRUE,
  cor_method = "pearson",
  scatterplots = TRUE,
  plotOpts = NULL,
  digits = NULL
)

Arguments

mat

data matrix (observations x variables) of numeric values

group

vector of grouping (factor-like) variables for each observation

col

a vector of colors for each unique group of points in the scatter plots; note that colors will be assigned to the sorted levels of group

labels

optional character vector or named list of character vectors to label each point; if NULL, points will be labeled by index

cluster

logical or function; if TRUE, the variables will be clustered and reordered; if FALSE, no reordering will be done; otherwise, a custom clustering function may be given; see details

cor_method

character string indicating which correlation coefficient is to be computed; one of 'pearson' (default), 'kendall', or 'spearman': can be abbreviated; see cor

scatterplots

logical; if TRUE, scatter plots of the linked underlying data will be included

plotOpts

list of additional plot options; see icorrOpts

digits

integer indicating number of significant digits to use

Details

If col is given with no group variable, the colors for each observation will be recycled in order.

Default cluster method is stats::hclust(dist(x), method = 'average') which will return a list containing a named vector, "order", which is used to reorder the variables.

In order to pass a custom clustering function to cluster, the function must take a single input (a correlation matrix) and return either a vector or a list with a named vector, "order".

See Also

iplotCorr from the qtlcharts package

saveWidget

Other iplots: icurve(), idot(), iscatter(), itree()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## heatmap only
icorr(mtcars, scatterplots = FALSE)

## with scatter plots
icorr(mtcars, group = mtcars$cyl, col = c('blue','red','green'),
      plotOpts = list(corcolors = heat.colors(3)))

## larger matrix example
set.seed(1)
dat <- replicate(50, mtcars[, sample(1:11, 1), drop = FALSE])
dat <- do.call('cbind', dat)
icorr(dat, cluster = TRUE, group = mtcars$cyl)

## using a custom clustering function
icorr(dat, cluster = function(x) hclust(dist(x, method = 'maximum')))
icorr(dat, cluster = function(x) sample(seq.int(ncol(x))))
icorr(dat, cluster = function(x) list(order = order(rowMeans(x))))

raredd/iplotr documentation built on March 19, 2021, 12:45 a.m.