0
votes

I have a dataset including several columns and I want to make a correlation plot between x and y. X and Y include several variables. For example in mtcars data from car library I want to have a correlation plot between (mpg, cyl, disp as X) and (hp, drat, wt as Y). How I can do it that R. Note: I want to have an output like "corrplot" output. The only difference is that I have different variables on x and y axes. Please see the attached file.

 library(car)
 data(mtcars)

enter image description here

1

1 Answers

2
votes

We can do

x <- mtcars[, c('mpg', 'cyl', 'disp')]
y <- mtcars[, c('hp', 'drat', 'wt')]
cor_mat <- cor(y, x)
corrplot::corrplot(cor_mat)

enter image description here