我可以在 R 中使用pairs() 函数并绘制默认图的子集吗? [英] Can I use pairs() function in R and plot a subset of the default plots?
问题描述
我正在尝试查找所选目标变量与数据集中其他变量之间的关系.例如,如果我考虑自动数据集,我会得到以下图.假设我的目标变量是 mpg
I am trying to find the relationship between a selected target variable and the other variables in a data set. For example, if I consider the auto dataset I get the following plot. Assume my target variable is mpg
library("ISLR")
pairs(Auto)
但是,我只想返回该图的第一行,因为我只对绘制目标变量与其他每个变量之间的关系感兴趣.我看过这篇文章,它使用了tidyverse
库并重新排列了我的数据框.
However, I would like to return only the first row of this plot since I'm only interested in plotting the relationship between the target variable and each of the other variables. I have seen this post which uses the tidyverse
library and rearranges my dataframe.
我希望有一种方法可以只使用 R 中的 pairs()
函数.
I'm hoping there's a way to do it using just the pairs()
function in R.
我正在寻找一种将变量名称保留在最终结果中的方法.
I'm looking for a way to keep the variable names in the final result.
推荐答案
在 ?pairs
中查找 horInd
和 verInd
.
Look for horInd
and verInd
in ?pairs
.
例如
pairs(mtcars, verInd = 1, horInd = 2:ncol(mtcars))
这篇关于我可以在 R 中使用pairs() 函数并绘制默认图的子集吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!