# Don't forget to load the ggplot2 package library(ggplot2)
2024
# Don't forget to load the ggplot2 package library(ggplot2)
geom_point()ggplot(data = mpg, aes(x = displ, y = hwy, color = class)) + geom_point()
geom_point()geom_line# Line Plot ggplot(data = mpg, aes(x = displ, y = hwy, color = class)) + geom_line()
geom_linegeom_smooth# Scatter Plot with a Smooth Line ggplot(data = mpg, aes(x = displ, y = hwy, color = class)) + geom_point() + geom_smooth()
geom_smoothgeom_bar# Bar Chart ggplot(data = mpg, aes(x = class, fill = class)) + geom_bar()
geom_bargeom_boxplot# Boxplot ggplot(data = mpg, aes(x = class, y = hwy, fill = class)) + geom_boxplot()
geom_boxplotgeom_violin# Violin Plot ggplot(data = mpg, aes(x = class, y = hwy, fill = class)) + geom_violin()
geom_violingeom_histogram# Histogram ggplot(data = mpg, aes(x = hwy)) + geom_histogram()
geom_histogramgeom_density# Density Plot ggplot(data = mpg, aes(x = hwy, fill = class)) + geom
geom_densityAdd a smooth line to the following plot that summarizes the relationship between these two variables.
ggplot(data = mpg, aes(x = displ, y = hwy, color = class)) + geom_point()
ggplot(data = mpg, aes(x = displ, y = hwy, color = class)) + geom_point() + geom_smooth()
Modify the following code to create a histogram exploring the distribution of highway miles per gallon (hwy) in the mpg dataset. Adjust the number of bins to refine the histogram’s granularity.
ggplot(data = mpg, aes(x = hwy))
ggplot(data = mpg, aes(x = hwy)) + geom_histogram(bins=100)