Dimitri Liakhovitski
2014-Nov-20 22:14 UTC
[R] ggplot question error: Error in s(x, bs = "cs") : object 'x' not found
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: library(ggplot2) sp10<-ggplot(temp,aes(x=p.used_L1,y=l.to.r.ratio_L1)) 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 ~ p.used_L1) Still, the same error message. Thanks a lot for your advice!
Dimitri Liakhovitski
2014-Nov-20 22:27 UTC
[R] ggplot question error: Error in s(x, bs = "cs") : object 'x' not found
Never mind, I found the problem. In my profile s was assigned to summary. This is why it did not work. On Thu, Nov 20, 2014 at 5:14 PM, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote:> 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: > > library(ggplot2) > sp10<-ggplot(temp,aes(x=p.used_L1,y=l.to.r.ratio_L1)) > 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 ~ > p.used_L1) > > Still, the same error message. > > Thanks a lot for your advice!-- Dimitri Liakhovitski
John Kane
2014-Nov-21 17:01 UTC
[R] ggplot question error: Error in s(x, bs = "cs") : object 'x' not found
Hi Dimitri, I am not sure I completely understand the issue but here is what I think you want (using my variable names :) ) library(ggplot2) dat1 <- data.frame(aa = sample(1:20, 100, replace = TRUE), bb = 1:100 ) p <- ggplot(dat1, aes(aa, bb)) + geom_point() p <- p + geom_smooth(se = FALSE) p John Kane Kingston ON Canada> -----Original Message----- > From: dimitri.liakhovitski at gmail.com > Sent: Thu, 20 Nov 2014 17:14:27 -0500 > To: r-help at r-project.org > Subject: [R] ggplot question error: Error in s(x, bs = "cs") : object 'x' > not found > > 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: > > library(ggplot2) > sp10<-ggplot(temp,aes(x=p.used_L1,y=l.to.r.ratio_L1)) > 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 ~ > p.used_L1) > > Still, the same error message. > > Thanks a lot for your advice! > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.____________________________________________________________ Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords & protects your account.