scenarios in plotting with ggplot2 when using stat_smooth with a custom formula
I've hit a wall trying to Can someone help me understand I'm having trouble using the `stat_smooth()` function from the `ggplot2` package in R... Specifically, I want to apply a custom polynomial regression formula to my scatter plot, but I'm working with an behavior that says `behavior in eval(expr, env) : object 'x' not found`. Here's the code I have so far: ```r library(ggplot2) set.seed(123) data <- data.frame(x = rnorm(100), y = rnorm(100)) # Basic scatter plot without smoothing works fine p <- ggplot(data, aes(x = x, y = y)) + geom_point() # Attempting to add a custom polynomial regression p + stat_smooth(method = "lm", formula = y ~ poly(x, 2), se = FALSE) ``` I expected this to plot the points along with a second-degree polynomial fit, but instead, I get the behavior mentioned above. I have tried running the code in a clean R session and also reloading the `ggplot2` package, but the scenario continues. Iām currently using `ggplot2` version 3.3.5. Could it be that the formula syntax is incorrect, or is there something else I might be missing? Any insights or suggestions would be greatly appreciated! I'm using R 3.11 in this project. Any help would be greatly appreciated! I'm open to any suggestions.