Plotting x-y data: associations

Author

Jeffrey R. Stevens

Published

April 17, 2023

  1. Using the mpg data, create a scatterplot of the highway fuel efficiency and city fuel efficiency.
# >
  1. Now add a dashed reference line showing equivalent values for the two axes and set the aspect ratio to 1.
# >
  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.
# >
  1. Add rugs to scatterplot #1 and change to minimal theme.
# >
  1. From scatterplot #1, color the dots by class, move the legend to the top left corner of the plot, and add marginal density plots.
# >
  1. Create a data frame called mpg_num that only includes variables with numeric values using the where() function. Then remove the year column.
# >
  1. Create correlation plots of the numeric variables in mpg_num in both base R and using {GGally}’s ggpairs() function.
# >
  1. 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.
# >