ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_poly_line()
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_poly_line(formula = x ~ y)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_poly_line(formula = y ~ poly(x, 3))
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_poly_line(formula = x ~ poly(y, 3))
# Smooths are automatically fit to each group (defined by categorical
# aesthetics or the group aesthetic) and for each facet.
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point() +
stat_poly_line(se = FALSE)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_poly_line() +
facet_wrap(~drv)
# Inspecting the returned data using geom_debug()
gginnards.installed <- requireNamespace("gginnards", quietly = TRUE)
if (gginnards.installed)
library(gginnards)
if (gginnards.installed)
ggplot(mpg, aes(displ, hwy)) +
stat_poly_line(geom = "debug")
if (gginnards.installed)
ggplot(mpg, aes(displ, hwy)) +
stat_poly_line(geom = "debug", fm.values = TRUE)
if (gginnards.installed)
ggplot(mpg, aes(displ, hwy)) +
stat_poly_line(geom = "debug", method = lm, fm.values = TRUE)
Run the code above in your browser using DataLab