dorien - 5 months ago 18

R Question

I want to use R to visualise and calculate the correlation of one variable data[1] to many other variables data[2:96]

I am already aware of what packages such as psych and PerformanceAnalytics have the Pairs function.

Ideally, I would like to output a graph like that Pairs outputs, but only for the correlations between data[1] and each of data[2:96], not for each of the elements of data[1:96] with itself, that would take up too much space. Any ideas on this would be appreciated.

Answer

Using `mtcars`

data and the `corrplot{}`

package:

```
install.packages("corrplot")
library(corrplot)
mcor <- cor(x = mtcars$mpg, y = mtcars[2:11], use="complete.obs")
corrplot(mcor, tl.srt = 25)
```

Edit: Forgot to put in a vignette for `corrplot`

showing more ways to format it: https://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.html