scenarios with `ggplot2` when trying to add a smooth line to a scatter plot with different group levels
I've hit a wall trying to I'm sure I'm missing something obvious here, but I'm running into an scenario when trying to add a smooth line to a scatter plot using `ggplot2`..... I want to create a scatter plot of `mpg` vs `wt` from the `mtcars` dataset and add a separate smooth line for each `cyl` (number of cylinders) group. However, I keep getting the following behavior: `behavior in eval(predvars, data, env) : object 'cyl' not found`. Here's the code that I'm using: ```r library(ggplot2) # Scatter plot with smooth lines for each cyl group ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) + geom_point() + geom_smooth(method = "lm", aes(group = factor(cyl))) ``` I thought that using `aes(group = factor(cyl))` inside `geom_smooth()` would help differentiate the smooth lines, but it seems like it's not recognizing `cyl` in that context. I've also tried removing the `group` aesthetic, but that results in only one overall smooth line. I'm using `ggplot2` version 3.3.5. Any insights on how to properly add these smooth lines? Thanks! I'm working on a service that needs to handle this. I'd really appreciate any guidance on this. How would you solve this?