Learn R Programming

ztable (version 0.2.3)

makeHeatmap: Add gradient background color to ztable

Description

Add gradient background color to ztable

Usage

makeHeatmap(
  z,
  palette = "Reds",
  mycolor = NULL,
  rows = NULL,
  cols = NULL,
  changeColor = TRUE,
  reverse = FALSE,
  margin = 0
)

Arguments

z

An object of class ztable

palette

Name of color palette

mycolor

user defined color vectors

rows

columns to make heatmap

cols

columns to make heatmap

changeColor

Logical. Whether of not change font color automatically

reverse

If true, reverse the font color

margin

An integer. Choices are one of 0,1 and 2. 0(default), heatmap for all numeric data. 1 ; rowwise heatmap, 2: columnwise heatmap.

Examples

Run this code
# NOT RUN {
require(magrittr)
ztable(head(mtcars)) %>% makeHeatmap()
# }
# NOT RUN {
ztable(head(mtcars)) %>% makeHeatmap(palette="YlOrRd",cols=c(1,4,6),margin=2)
ztable(head(mtcars)) %>% makeHeatmap(rows=c(1,3,5),margin=1)
require(moonBook)
x=table(acs$smoking,acs$Dx)
ztable(x) %>% makeHeatmap
ztable(x) %>% makeHeatmap(palette="Blues")
ztable(x) %>% makeHeatmap(mycolor=gradientColor(low="yellow",mid="orange",high="red"))
# }

Run the code above in your browser using DataLab