library(dplyr)
# Basic example with long format correlation data
# Make some correlation data in long format
cor_dat <- cor(mtcars)
hm_in <- data.frame(row = rep(colnames(cor_dat), ncol(cor_dat)),
col = rep(colnames(cor_dat), each = ncol(cor_dat)),
val = as.vector(cor_dat))
ggcorrhm_tidy(hm_in, row, col, val,
# Indicate that the data consists of correlation coefficients
cor_in = TRUE)
# Or let the function compute the correlations
# (this limits some other functionality, see details)
raw_dat <- data.frame(row = rep(rownames(mtcars), ncol(mtcars)),
col = rep(colnames(mtcars), each = nrow(mtcars)),
val = unlist(mtcars))
ggcorrhm_tidy(raw_dat, row, col, val, cor_in = FALSE)
Run the code above in your browser using DataLab