Use network_plot to visualise correlation matrix in R

Viewed 284

I want to visualise the correlation matrix of 60+ attributes. I've tried 'library(corrplot)' and the result shows warning: "too many overlap". Then I tried, which shows a messy plot that the labels are too large and the curves are overlapping.

library(corrr)
data %>% correlate() %>% network_plot(min_cor = 0.4)

I tried to adjust the label size and curve width following https://www.rdocumentation.org/packages/memnet/versions/0.1.0/topics/network_plot, it shows error:

Error in network_plot(correlate(data), min_cor = 0.4, nod_cex = 2, : unused arguments (nod_cex = 2, lab_cex = 1, lab_lwd = 2)

enter image description here

1 Answers

memnet is a deprecated package that has been removed from CRAN so this is normal you can't use the network_plot from this package, but here you are using the network_plot function from the corrr package which haven't the same arguments : https://www.rdocumentation.org/packages/corrr/versions/0.4.3/topics/network_plot

With 60 variables, I don't think network_plot is the best option for visualisation. However, you can try to use corrplot as follows :

#Create a data frame with random values
df=data.frame(replicate(60,sample(0:60,10,rep=TRUE)))
cor=cor(df)
cor2 <- corrplot::corrMatOrder(cor, order = "FPC", hclust.method = "average")
corrplot::corrplot(cor[cor2,cor2], diag = F, type = "lower",
                       method = "color",  mar = c(1,1,3,1), tl.srt = 60, tl.cex = 0.4)

This will produce this graph which will be far more interpretable : enter image description here

Related