Question
What are some good plotting methods in R for examining the relationship between a target variable and various explanatory variables? In particular, I'm looking for visualization techniques that scale to more variables than the traditional scatterplot matrix.
More details
The scatterplot matrix is a great tool for visualizing pairwise relationships between variables. For example, with the swiss
dataset in R, we can easily plot a matrix of scatterplots.
library(datasets)
data(swiss)
plot(swiss[1:3])
which yields
I am interested in the case where I want to predict some response, say Fertility
using some combination of explanatory variables. I want to closely examine how each explanatory variable correlates with Fertility
. If I have many columns in my dataframe, using plot(swiss)
becomes unwieldy.
For example, the following plot (generated following instructions here) shows pairwise correlations for all columns in a dataframe. If I could plot something like this but only showing correlations between Fertility
and other columns, that would be useful.
library(datasets)
data(swiss)
plot(swiss[1:3])
library(devtools)
library(inspectdf)
library(tidyverse)
library(readr)
show_plot(inspect_cor(swiss))
which yields