# NOT RUN {
# use first 20 columns from HCI dataset (the remainder are not items)
HCI <- HCI[, 1:20]
# use Pearson product-moment correlation coefficient for matrix computation
plot_corr(HCI, cor = "pearson")
# }
# NOT RUN {
# use tetrachoric correlation and reorder the resulting heatmap
# using Ward's method
HCI %>% plot_corr(cor = "tetra", clust_method = "ward.D")
# outline 3 Ward's clusters with bold yellow line and add labels
HCI %>%
plot_corr(
n_clust = 3, clust_method = "ward.D", line_col = "yellow",
line_size = 1.5, labels = TRUE
)
# add title and position the legend below the plot
library(ggplot2)
HCI %>% plot_corr(n_clust = 3) +
ggtitle("HCI heatmap") +
theme(legend.position = "bottom")
# mimic the look of corrplot package
plot_corr(HCI, cor = "poly", clust_method = "complete", shape = "sq") +
scale_fill_gradient2(
limits = c(-.1, 1),
breaks = seq(-.1, 1, length.out = 12),
guide = guide_colorbar(
barheight = .8, barwidth = .0275,
default.unit = "npc",
title = NULL, frame.colour = "black", ticks.colour = "black"
)
) + theme(axis.text = element_text(colour = "red", size = 12))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab