xixixixi
xixixixi

Reputation: 1

Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow = nr, : 'dimnames' length [2] must be the same as the displayed area

I want to use cprrplot for visualization, but there is an error

dataset1 <- read.csv("winequality-white.csv",header=T) View(dataset1) head(dataset1) fixed.acidity volatile.acidity citric.acid residual.sugar chlorides free.sulfur.dioxide total.sulfur.dioxide density pH sulphates alcohol 1 7.0 0.27 0.36 20.7 0.045 45 170 1.0010 3.00 0.45 8.8 2 6.3 0.30 0.34 1.6 0.049 14 132 0.9940 3.30 0.49 9.5 3 8.1 0.28 0.40 6.9 0.050 30 97 0.9951 3.26 0.44 10.1 4 7.2 0.23 0.32 8.5 0.058 47 186 0.9956 3.19 0.40 9.9 5 7.2 0.23 0.32 8.5 0.058 47 186 0.9956 3.19 0.40 9.9 6 8.1 0.28 0.40 6.9 0.050 30 97 0.9951 3.26 0.44 10.1 dataset1 <- read.csv("winequality-white.csv",header=T) View(dataset1) M<-cor(dataset1) library(corrplot)

correlogram with hclust reordering

corrplot(dataset1, type ="upper", order="hclust") Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow = nr, : 'dimnames'的长度[2]必需与陈列范围相等 corrplot(as.matrix(dataset1), type="upper", order="hclust") Error in corrplot(as.matrix(dataset1), type = "upper", order = "hclust") : The matrix is not in [-1, 1]!

enter image description here

Upvotes: 0

Views: 965

Answers (1)

WimZhai
WimZhai

Reputation: 1

The correct way to debug this ERROR is as follows:

library("corrplot")
dataset1 <- read.csv("winequality-white.csv",header=T) 
# Below is the keypoint!
cor_dataset1 <- cor(datset1)  
corrplot(cor_dataset1, type ="upper", order="hclust")

Upvotes: 0

Related Questions