# Amend the plot to add another smooth layer with dummy grouping
fcyl=factor(mtcars$cyl)
ggplot(mtcars, aes(x = wt, y = mpg, color = fcyl)) +
geom_point() +
stat_smooth(method = "lm", se = FALSE) +
stat_smooth(method = "lm", se = FALSE, aes(group=1))
I don't understand aes(group=1) in the last line. Can anyone explain it? A very similar question is:
# Amend the plot
ggplot(mtcars, aes(x = wt, y = mpg, color = fcyl)) +
geom_point() +
# Map color to dummy variable "All"
stat_smooth(aes(color = "All"), se = FALSE) +
stat_smooth(method = "lm", se = FALSE)
I don't understand # Map color to dummy variable "All". (aes(color = "All"))
yeah, its a dummy grouping variable. the same is used for every value, so they are in a common group, whether that common group has the value, 1 , or 2 or anything else, is irrelevant to its use.