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)
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.
I'm hoping there's a way to do it using just the pairs()
function in R.
Edit: I'm looking for a way to keep the variable names in the final result.