createHeatmap: Create Heat Map type of plot.

Description Usage Arguments Value See Also Examples

Description

Create heat map visualization of 2D matrix from the data frame data pre-computed with computeHeatmap.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
createHeatmap(data, x, y, fill, facet = NULL, ncol = 1, baseSize = 12,
  baseFamily = "sans", thresholdValue = NULL, thresholdName = fill,
  text = FALSE, textFill = fill, percent = FALSE,
  digits = ifelse(percent, 2, 4), divergingColourGradient = FALSE,
  lowGradient = ifelse(divergingColourGradient, muted("red"), "#56B1F7"),
  midGradient = "white", highGradient = ifelse(divergingColourGradient,
  muted("blue"), "#132B43"), title = paste("Heatmap by", fill),
  subtitle = NULL, xlab = x, ylab = y, legendPosition = "right",
  fillGuide = "colorbar", defaultTheme = theme_tufte(base_size = baseSize,
  base_family = baseFamily), themeExtra = NULL)

Arguments

data

data frame contains data computed for heatmap

x

name of a column containing x variable values (1st or horizontal dimenstion) in 2D matrix

y

name of a column containing y variable values (2d or vertical dimension) in 2D matrix

fill

name of a column with values to map to heatmap gradient colors (lowGradient, highGradient, and optionally midGradient).

facet

vector of 1 or 2 column names to split up data to plot the subsets as facets. If single name then subset plots are placed next to each other, wrapping with ncol number of columns (uses facet_wrap). When two names then subset plots vary on both horizontal and vertical directions (grid) based on the column values (uses facet_grid).

ncol

number of facet columns (applies when single facet column supplied only - see parameter facet).

baseSize

theme base font size

baseFamily

theme base font family

thresholdValue

threshold to use to display data in heatmap (if NULL then do not use threshold)

thresholdName

name of data attribute from data to use (by defult use fill)

text

if TRUE then display values in heatmap table (default: FALSE)

textFill

text to display (applies only when text is TRUE), by defaul use fill values

percent

format text as percent

digits

number of digits to use in text

divergingColourGradient

logical diverging colour gradient places emphasize on both low and high leaving middle neutral. Use when both end grandient colours represent critical values such as negative and positive extremes (e.g. temprature, outliers, etc.).

lowGradient

colour for low end of gradient.

midGradient

colour for mid point.

highGradient

colour for high end of gradient.

title

plot title.

subtitle

plot subtitle.

xlab

a label for the x axis, defaults to a description of x.

ylab

a label for the y axis, defaults to a description of y.

legendPosition

the position of legends. ("left", "right", "bottom", "top", or two-element numeric vector). "none" is no legend.

fillGuide

Name of guide object, or object itself for the fill. Typically "colorbar" name or object guide_colourbar.

defaultTheme

plot theme settings with default value theme_tufte. More themes are available here: ggtheme (by ggplot2) and ggthemes.

themeExtra

any additional theme settings that override default theme.

Value

ggplot object

See Also

computeHeatmap for computing data for heat map

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
if(interactive()){
# initialize connection to Lahman baseball database in Aster 
conn = odbcDriverConnect(connection="driver={Aster ODBC Driver};
                         server=<dbhost>;port=2406;database=<dbname>;uid=<user>;pwd=<pw>")

hm = computeHeatmap(conn, "teams_enh", 'franchid', 'decadeid', 'avg(w) w', 
                    where="decadeid >= 1950")
hm$decadeid = factor(hm$decadeid)
createHeatmap(hm, 'decadeid', 'franchid', 'w')

# with diverging color gradient
hm = computeHeatmap(conn, "teams_enh", 'franchid', 'decadeid', 'avg(w-l) wl', 
                    where="decadeid >= 1950")
hm$decadeid = factor(hm$decadeid)
createHeatmap(hm, 'decadeid', 'franchid', 'wl', divergingColourGradient = TRUE)
}

teradata-aster-field/toaster documentation built on May 31, 2019, 8:36 a.m.