【问题标题】:Error in GGally: Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length > 0GGally 中的错误:单位错误(tic_pos.c,“mm”):“x”和“单位”的长度必须 > 0
【发布时间】:2015-04-03 01:29:50
【问题描述】:

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

有 13 个属性,第 13 个属性是类。第一个属性只是 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

【问题讨论】:

    标签: r plot ggally


    【解决方案1】:

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

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

    #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'))
    

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

    【讨论】:

    • 好的,太好了!谢谢。同样,我将对其应用 kmeans 并比较数据。谢谢
    • 太棒了!乐于助人:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    • 2021-07-19
    • 1970-01-01
    • 2020-06-14
    • 2015-02-05
    • 1970-01-01
    相关资源
    最近更新 更多