GGally 中的错误:单元错误(tic_pos.c、"mm"):'x' 和 'units' 的长度必须 > 0

Error in GGally: Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length > 0

我正在尝试为我的数据集生成一个可以找到的图 here

有 13 个属性,第 13 个属性是 class。第一个属性只是 ID,所以我想忽略它。

我尝试创建这样的图表,但出现错误

> ggpairs(wine[2:13], columns=2:12,
+         colour='q', lower=list(continuous='points'),
+         axisLabels='none',
+         upper=list(continuous='blank'))
Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length > 0

首先你的列错了,然后你的颜色错了,这就是导致上述错误的原因:

代码应该如下所示,我将其拆分了一下以使其更有意义:

#load data
wine <- read.csv("wine_nocolor.csv")
#remove first column
wine1 <- wine[2:13]
#The colour column needs to be of factor class
wine1$q <- factor(wine1$q)

library(GGally)
#and now you need to pick the correct columns i.e. from 1 to 11 as you don't 
#need the last column
ggpairs(wine1, columns=1:11,
        colour='q',lower=list(continuous='points'),
        axisLabels='none',
        upper=list(continuous='blank'))

将颜色列作为因素并选择正确的列可得到您想要的输出: