2

ここにあるデータセットのプロットを生成しようとしています

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
4

1 に答える 1

4

まず、列が間違っていて、次に色が間違っているため、上記のエラーが発生します。

コードは次のようになりますが、わかりやすくするために少し分割しています。

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

色の列を要因として使用し、正しい列を選択すると、必要な出力が得られます。

ここに画像の説明を入力

于 2015-04-02T17:29:50.320 に答える