Relationship ggplot()
October 28, 2024
ggplot()
ggplot()
geom_point()
ggplot()
geom_smooth()
ggplot()
geom_point()
with geom_smooth()
geom_smooth()
draws a smooth curve fitted to the data.ggplot()
workflowggplot()
ggplot2
graphics is to put the +
in the wrong place.
+
at the end of the previous line, NOT at the beginning of the next line.ggplot()
geom_smooth()
Using regression—one of the machine learning methods—the geom_smooth()
visualizes the predicted value of the y
variable for a given value of the x
variable.
What Does the Grey Ribbon Represent?
x
and y
variables falls within the grey ribbon.ggplot()
geom_point()
with geom_smooth(method = lm)
method = "lm"
specifies that a linear model (lm
), called a linear regression model.ggplot()
mpg
data.frame?ggplot()
Many points overlap each other.
When points overlap, it’s hard to know how many data points are at a particular location.
Overplotting can obscure patterns and outliers, leading to potentially misleading conclusions.
ggplot()
alpha
alpha
) between 0 (full transparency) and 1 (no transparency) manually.ggplot()
alpha
aes()
function but within the geom_*()
function.ggplot()
ggplot()
ggplot()