2
$\begingroup$

I found some code online that uses the ggpairs() function from R to draw a scatter plot matrix for the famous iris dataset.

library(GGally)
ggpairs(iris, columns = 1:4, aes(color = Species)) + 
    ggtitle("Anderson's Iris Data -- 3 species")

enter image description here

What do the class-specific (in this case species) numbers mean? For example, in the Sepal.Width and Sepal.Length rectangle, we have the numbers "setosa: 0.743" and "versicolor: 0.526". I am aware that "Cor: -0.118" indicates the correlation between Sepal.Width and Sepal.Length.

$\endgroup$

1 Answer 1

1
$\begingroup$

You have 3 species in the iris dataset (under Species column). In your ggplot, you specified color = Species, this groups the observations by that the Species columns, gives you the different colours and also correlation within each species.

For example if we :

by(iris[,1:4],iris$Species,cor,method="spearman)
iris$Species: setosa
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length    1.0000000   0.7425467    0.2671758   0.2780984
Sepal.Width     0.7425467   1.0000000    0.1777000   0.2327520
Petal.Length    0.2671758   0.1777000    1.0000000   0.3316300
Petal.Width     0.2780984   0.2327520    0.3316300   1.0000000
------------------------------------------------------------ 
iris$Species: versicolor
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length    1.0000000   0.5259107    0.7540490   0.5464611
Sepal.Width     0.5259107   1.0000000    0.5605221   0.6639987
Petal.Length    0.7540490   0.5605221    1.0000000   0.7866681
Petal.Width     0.5464611   0.6639987    0.7866681   1.0000000
------------------------------------------------------------ 
iris$Species: virginica
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length    1.0000000   0.4572278    0.8642247   0.2811077
Sepal.Width     0.4572278   1.0000000    0.4010446   0.5377280
Petal.Length    0.8642247   0.4010446    1.0000000   0.3221082
Petal.Width     0.2811077   0.5377280    0.3221082   1.0000000

You can see for setosa, correlation between sepal.length and sepal.width is 0.743, for versicolor it is 0.526 and so on

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.