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

假如想象 提交于 2019-12-11 04:03:11

问题


I'm trying to generate a plot for my dataset that can be found here

There are 13 attributes with 13th attribute being the class. The first attribute is just ID so I want to ignore it.

I try to create the graph like this but I'm getting an error

> 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

回答1:


First of all you have the columns wrong and then you got the colour wrong which is what gives the above error:

The code should be like the following and I split it up a bit to make more sense:

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

Having the colour column as factor and picking the correct columns gives the output you want:



来源:https://stackoverflow.com/questions/29418515/error-in-ggally-error-in-unittic-pos-c-mm-x-and-units-must-have-leng

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!