Re: [R] Using $ accessor in GAM formula

2011-05-10 Thread Gene Leynes
Gavin, Yes, I thought I was responding to Berwin, whoops! Since I'm often mixing different data frames, I rarely use this formulation: gam(y ~ s(x), dat) Actually, I often forget about that syntax, and it's a good reminder. It really is much easier to read. In my "real" model that people actua

Re: [R] Using $ accessor in GAM formula

2011-05-06 Thread Gavin Simpson
On Fri, 2011-05-06 at 11:20 -0500, Gene Leynes wrote: > Hmmm > > After reading that email four times, I think I see what you mean. > > Checking for variables within particular scopes is probably one of the most > challenging things in R, and I would guess in other languages too. In R > it's

Re: [R] Using $ accessor in GAM formula

2011-05-06 Thread Gene Leynes
Hmmm After reading that email four times, I think I see what you mean. Checking for variables within particular scopes is probably one of the most challenging things in R, and I would guess in other languages too. In R it's compounded by situations when you're writing a function to accept va

Re: [R] Using $ accessor in GAM formula

2011-05-06 Thread Berwin A Turlach
G'day Rolf, On Fri, 06 May 2011 09:58:50 +1200 Rolf Turner wrote: > but it's strange that the dodgey code throws an error with gam(dat1$y > ~ s(dat1$x)) but not with gam(dat2$cf ~ s(dat2$s)) > Something a bit subtle is going on; it would be nice to be able to > understand it. Well, R> trac

Re: [R] Using $ accessor in GAM formula

2011-05-05 Thread Rolf Turner
On 06/05/11 07:05, P Ehlers wrote: Gene, David has given you the preferred code. I just want to point out that the $-accessor is often not the best thing to use. Both dat[["y"]] and dat[, "y"] will work just fine. Admittedly one should use the preferred code, i.e. gam(y ~ s(x),data=dat) and av

Re: [R] Using $ accessor in GAM formula

2011-05-05 Thread P Ehlers
Gene, David has given you the preferred code. I just want to point out that the $-accessor is often not the best thing to use. Both dat[["y"]] and dat[, "y"] will work just fine. Peter Ehlers On 2011-05-05 12:06, David Winsemius wrote: On May 5, 2011, at 1:08 PM, Gene Leynes wrote: This is

Re: [R] Using $ accessor in GAM formula

2011-05-05 Thread David Winsemius
On May 5, 2011, at 1:08 PM, Gene Leynes wrote: This is not mission critical, but it's bothering me. I'm getting inconsistent results when I use the $ accessor in the gam formula *In window #1:* library(mgcv) dat=data.frame(x=1:100,y=sin(1:100/50)+rnorm(100,0,.05)) str(dat) gam(dat$y~s(dat$x)

[R] Using $ accessor in GAM formula

2011-05-05 Thread Gene Leynes
This is not mission critical, but it's bothering me. I'm getting inconsistent results when I use the $ accessor in the gam formula *In window #1:* > library(mgcv) > dat=data.frame(x=1:100,y=sin(1:100/50)+rnorm(100,0,.05)) > str(dat) > gam(dat$y~s(dat$x)) Error in eval(expr, envir, enclos) : objec