Complete the code to create a basic scatter plot using ggplot2.
library(ggplot2)
ggplot(data = mtcars, aes(x = wt, y = mpg)) + geom_[1]()The geom_point() function creates a scatter plot in ggplot2, which is the basic geometric object for points.
Complete the code to map the color aesthetic to the variable 'cyl' in the plot.
ggplot(mtcars, aes(x = wt, y = mpg, color = [1])) + geom_point()Mapping color = cyl colors the points based on the number of cylinders, adding an informative visual grouping.
Fix the error in the code to add a title to the plot using ggtitle().
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + ggtitle([1])The title text must be a string, so it needs to be enclosed in quotes like "mpg vs wt".
Fill both blanks to create a histogram of 'mpg' with blue fill color.
ggplot(mtcars, aes(x = [1])) + geom_histogram(fill = [2])
The histogram should use mpg for the x-axis and fill color set to the string "blue".
Fill all three blanks to create a boxplot of 'mpg' grouped by 'cyl' with green boxes and a title.
ggplot(mtcars, aes(x = [1], y = [2])) + geom_boxplot(fill = [3]) + ggtitle("MPG by Cylinders")
The x-axis groups by cyl, y-axis shows mpg, and the boxplot fill color is "green".