- Using the
mpg
data, create a scatterplot of the highway fuel efficiency and city fuel efficiency.
- Now add a dashed reference line showing equivalent values for the two axes and set the aspect ratio to 1.
- Looks like there is a possibility of overplotting. Turn this into a bubble chart with dot size scaling to the number of data points for each dot and make the dot colors steelblue.
- Add rugs to scatterplot #1 and change to minimal theme.
- From scatterplot #1, color the dots by class, move the legend to the top left corner of the plot, and add marginal density plots.
- Create a data frame called
mpg_num
that only includes variables with numeric values using the where()
function. Then remove the year column.
- Create correlation plots of the numeric variables in
mpg_num
in both base R and using {GGally}’s ggpairs()
function.
- Create a correlation matrix of
mpg_num
with the cor()
function. Then use ggcorrplot()
from the {ggcorrplot} package to make a heatmap correlation plot with just the upper triangle of the matrix and using circles to represent correlation coefficient magnitude.