我正在尝试使用GGally
包绘制虹膜数据集
> library(GGally)
> ggpairs(iris, columns=c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"), colour='Species', lower=list(continuous='points'), axisLabels='none', upper=list(continuous='blank'))
Error in ggpairs(iris, columns = c("Sepal.Length", "Sepal.Width", "Petal.Length", :
Make sure your 'columns' values are less than 5.
columns = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)
为什么它抱怨列值的数量。它不能用于超过 5 列吗?
我还想运行 k-means,然后将结果与实际结果进行比较,但这也会产生类似的错误:
> set.seed(1234)
> iris$Cluster <- factor(kmeans(iris[,c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")], centers=length(levels(iris$Species)))$cluster)
> ggpairs(iris, columns=c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"), colour='Cluster', lower=list(continuous='points'), axisLabels='none', upper=list(continuous='blank'))
Error in ggpairs(iris, columns = c("Sepal.Length", "Sepal.Width", "Petal.Length", :
Make sure your 'columns' values are less than 6.
columns = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)