Skip to content

Instantly share code, notes, and snippets.

View jlehtoma's full-sized avatar

Joona Lehtomäki jlehtoma

  • Helsinki
View GitHub Profile
@dsparks
dsparks / Heatmap.R
Last active August 19, 2022 06:54
ggplot2 heatmap with "spectral" palette
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("ggplot2", "reshape2", "RColorBrewer")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Generate a random matrix
# This can be any type of numeric matrix,
# though we often see heatmaps of square correlation matrices.
nRow <- 9
nCol <- 16