# Basic example
set.seed(123)
hm_in <- data.frame(row = rep(letters[1:10], each = 5),
col = rep(LETTERS[1:5], 10),
val = rnorm(50))
gghm_tidy(hm_in, row, col, val)
# Annotation and clustering
# Add annotation by giving names of columns in the data
hm_in$row_annot1 <- rep(1:10, each = 5)
hm_in$row_annot2 <- rep(10:1, each = 5)
hm_in$col_annot <- rep(letters[1:5], 10)
# Columns are given using 'tidy' selection
# so they can be unquoted, quoted, from variables (with !! notation) or indices
gghm_tidy(hm_in, row, col, val,
annot_rows = c(row_annot1, row_annot2),
annot_cols = col_annot,
cluster_rows = TRUE,
cluster_cols = TRUE)
# Add cell labels
hm_in$lab <- 1:50
gghm_tidy(hm_in, row, col, val,
labels = lab, cell_label_col = "white")
Run the code above in your browser using DataLab