How to use corrplot with simple matrices
Asked Answered
I

1

12

I have a simple 8 by 8 matrix

M <- matrix(rnorm(64), nrow=8, ncol=8) 

How should I transform it to plot it with library(corrplot)? Without transformation the error is:

corrplot.mixed(M)

Error in corrplot(corr, type = "upper", method = upper, diag = TRUE, tl.pos = tl.pos, : The matrix is not in [-1, 1]! which I guess would assume that the matrix should be [-1, 1]?

Infernal answered 5/10, 2014 at 12:43 Comment(0)
B
21

Just indicate that it is not a correlation matrix:

library(corrplot)
corrplot(M, is.corr = FALSE, method = "square")

enter image description here

Bennion answered 5/10, 2014 at 12:55 Comment(2)
What if it is a correlation matrix?Electroshock
Then you can do: corrplot(cor(M)). This will use a correlation matrix for the M matrix (with pearson method as default).Workhouse

© 2022 - 2024 — McMap. All rights reserved.