[R] ggplot question error: Error in s(x, bs = "cs") : object 'x' not found

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Thu Nov 20 23:14:27 CET 2014

Dear R-ers,

apologies for not providing the full code. I just need a point in the
right direction.
I have a data frame ('temp') with 1,200 rows and 2 variables.
I am using ggplot2 to create a scatter plot:

This is my code and it works fine, it creates a scatter plot:

sp10 + geom_point()

However, when I change the last line to:
sp10 + geom_point() + stat_smooth(se=FALSE)

Then I am getting these messages (and no fitted line on the graph):

geom_smooth: method="auto" and size of largest group is >=1000, so
using gam with formula: y ~ s(x, bs = "cs"). Use 'method = x' to
change the smoothing method.
Error in s(x, bs = "cs") : object 'x' not found

I don't understand what x in in s(x, bs = "cs") is or should be.
I lookeed up ?geom_smooth and tried this:

sp10 + geom_point() + stat_smooth(se=FALSE,formula = l.to.r.ratio_L1 ~

Still, the same error message.

Thanks a lot for your advice!

More information about the R-help mailing list