library(ggcorrplot)
data(mtcars)
corr = cor(mtcars)
corr
get_upper_tri <- function(cormat, show.diag = FALSE) {
if (is.null(cormat)) {
return(cormat)
}
cormat[lower.tri(cormat)] <- NA
if (!show.diag) {
diag(cormat) <- NA
}
return(cormat)
}
get_upper_tri(corr)
get_upper_tri(corr)
get_upper_tri(corr,show.diag = T)
