Q:

How to create graph for Boston Dataset in r

My data is "Boston Housing Dataset", I want to produce a graphic that looks like this:
the code for the plot is in Python (unfortunately, I do not know python only r). link for the Code: kaggle.com/prasadperera/the-boston-housing-dataset .
but instead of y='medv' i need y='crim' with all the rest of the variable, in order to find predictors that have an interesting association with the crime.
 I have tried to do this in r, my code is:
Very appreciative of the help, Thanks!

A:

One way to do something similar in ggplot is with faceting. Here's what that might look like
library(ggplot2)
library(dplyr)
library(tidyr)
data(Boston, package="MASS")

Boston %>% 
  select(crim, lstat, indus, nox, ptratio, rm, tax, dis, age) %>% 
  gather(obs, val, -crim) %>% 
  ggplot(aes(val, crim, color=obs, fill=obs)) + 
  geom_smooth(method="lm", se=TRUE) +
  geom_point() +
  facet_wrap(~obs, scales="free_x") +
  scale_color_discrete(guide=FALSE) + 
  scale_fill_discrete(guide=FALSE)

The basic key is to reshape the data so you can draw just one plot and facet it rather than drawing many plots and arranging them.

