d3heatmap is designed to have a familiar feature set and API for anyone who has used heatmap or heatmap.2 to create static heatmaps. You can specify dendrogram, clustering, and scaling options in the same way.
d3heatmap includes the following features:
Shows the row/column/value under the mouse cursor
Click row/column labels to highlight
Drag a rectangle over the image to zoom in
Here’s a very simple example (source: flowingdata):
library(d3heatmap) url <- "http://datasets.flowingdata.com/ppg2008.csv" nba_players <- read.csv(url, row.names = 1) d3heatmap(nba_players, scale = "column")
You can easily customize the colors using the
colors parameter. This can take an RColorBrewer palette name, a vector of colors, or a function that takes (potentially scaled) data points as input and returns colors.
Let’s modify the previous example by using the
"Blues" colorbrewer palette, and dropping the clustering and dendrograms:
d3heatmap(nba_players, scale = "column", dendrogram = "none", color = "Blues")
If you want to use discrete colors instead of continuous, you can use the
col_* functions from the scales package.
d3heatmap(nba_players, scale = "column", dendrogram = "none", color = scales::col_quantile("Blues", NULL, 5))
d3heatmap(nba_players, colors = "Blues", scale = "col", dendrogram = "row", k_row = 3)
For issue reports or feature requests, please see our GitHub repo.
In this series, we walk through lesser-known tips and tricks to help you work more effectively and efficiently in R Markdown. This first post focuses on working with R Markdown in the RStudio IDE.
Announcing the 2021.10.0 release of the RStudio Professional Drivers, with single sign-on (SSO) for Hive and Impala.