R 中两个数据帧之间的相关图(相关热图)
Correlation plot between two data frames in R (Correlation heatmap)
我有一个包含多个列的数据集,我想制作一个
x 和 y 之间的相关图。 X 和 Y 包括几个变量。
例如,在汽车图书馆的 mtcars 数据中,我想要一个
(mpg, cyl, disp as X) 和 (hp, drat, wt as) 之间的相关图
Y).我该怎么做 R。注意:我想要一个像 "corrplot" 这样的输出。唯一的区别是我在 x 轴和 y 轴上有不同的变量。请看附件。
library(car)
data(mtcars)
我们可以做到
x <- mtcars[, c('mpg', 'cyl', 'disp')]
y <- mtcars[, c('hp', 'drat', 'wt')]
cor_mat <- cor(y, x)
corrplot::corrplot(cor_mat)
我有一个包含多个列的数据集,我想制作一个 x 和 y 之间的相关图。 X 和 Y 包括几个变量。 例如,在汽车图书馆的 mtcars 数据中,我想要一个 (mpg, cyl, disp as X) 和 (hp, drat, wt as) 之间的相关图 Y).我该怎么做 R。注意:我想要一个像 "corrplot" 这样的输出。唯一的区别是我在 x 轴和 y 轴上有不同的变量。请看附件。
library(car)
data(mtcars)
我们可以做到
x <- mtcars[, c('mpg', 'cyl', 'disp')]
y <- mtcars[, c('hp', 'drat', 'wt')]
cor_mat <- cor(y, x)
corrplot::corrplot(cor_mat)