Complete the code to create a basic scatter plot using ggplot2.
library(ggplot2)
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_[1]()The correct function to add points in ggplot2 is geom_point().
Complete the code to add a title to the plot.
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + ggtitle([1])The title text must be a string, so it needs to be in quotes like "mpg vs wt".
Fix the error in the code to change the color of points to blue.
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(color = [1])Colors in ggplot2 must be specified as strings, so use "blue".
Fill both blanks to customize the plot with a theme and axis labels.
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(color = "blue") + [1]() + [2](title = "Car Data", x = "Weight", y = "Miles per Gallon")
labels() instead of labs().theme_minimal() applies a clean theme, and labs() sets axis labels and title.
Fill all three blanks to create a customized scatter plot with color, size, and theme.
ggplot(mtcars, aes(x = wt, y = mpg, color = [1], size = [2])) + geom_point() + [3]()
Color is mapped to the number of cylinders (cyl), size to horsepower (hp), and theme_light() applies a light theme.
