O'Reilly logo

Data Analysis with R - Second Edition by Tony Fischetti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comparing multiple correlations

Armed with our new standardized coefficients, we can now effectively compare the correlations between different pairs of variables directly.

In data analysis, it is common to compare the correlations between all the numeric variables in a single dataset. We can do this with the iris dataset using the following R code snippet:

 # have to drop 5th column (species is not numeric) 
 iris.nospecies <- iris[, -5] 
 cor(iris.nospecies) 
               Sepal.Length Sepal.Width Petal.Length Petal.Width 
  Sepal.Length    1.0000000  -0.1175698    0.8717538   0.8179411 
  Sepal.Width    -0.1175698   1.0000000   -0.4284401  -0.3661259 
  Petal.Length    0.8717538  -0.4284401    1.0000000   0.9628654 
  Petal.Width     0.8179411  -0.3661259    0.9628654   1.0000000 

This produces a correlation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required