Visualise the correlation of multiple of variables with another group of variables in R

13 Views Asked by At

I have a dataframe with 8 columns of variables. I want to visualize the correlation of 3 variables with that of the other 5 variables. So I would like to correlate A/B/C with D/E. Example of a dataset:

df <- data.frame(A = c(1,4,6,7,8,4,6,3,2),
                 B = c(4,2,6,7,4,3,5,3,7),
                 C = c(2,5,4,2,3,6,8,5,2),
                 D = c(1,5,2,4,6,34,7,8,32),
                 E = c(4,5,7,3,5,2,4,7,4))

An example of the figure would look something like this: (https://i.stack.imgur.com/QHTRy.png)

I have tried corrplot, but can't figure it out. What I tried before

library(corrplot)
c1 <- corrplot(cor(x = df[1:3], y =df[4:5], use = "pairwise.complete.obs"),
         col = colorRampPalette(c("blue","white","red"))(100),
         addgrid.col = T,
         type = 'upper',
         addCoef.col = T,
         number.cex = 1.5,
         diag = T,
         tl.cex = 1,
         tl.col = "black",
         bg = "gray92")
0

There are 0 best solutions below