On May 28, 2017 1:53:29 PM PDT, Rui Barradas <ruipbarradas at sapo.pt> wrote:> > predict.bs(SCurve, xnew = 40:45) > Error in predict.bs(SCurve, xnew = 40:45) : > could not find function "predict.bs"You should call it using the generic, i.e. predict(SCurve, xnew = 40:45) On 29/05/2017 2:35 AM, Jeff Newmiller wrote:> Looks like it is not exported from the package namespace... a packaging error. >It's not an error to rely on the generic to get to a method. Duncan Murdoch
Hello, Em 29-05-2017 10:43, Duncan Murdoch escreveu:> > On May 28, 2017 1:53:29 PM PDT, Rui Barradas <ruipbarradas at sapo.pt> wrote: >> > predict.bs(SCurve, xnew = 40:45) >> Error in predict.bs(SCurve, xnew = 40:45) : >> could not find function "predict.bs" > > You should call it using the generic, i.e. > > predict(SCurve, xnew = 40:45)Thanks, I should have tested that. Just did and it (obviously) worked, giving the same result as splines:::predict.bs(...). Rui Barradas> > > On 29/05/2017 2:35 AM, Jeff Newmiller wrote: >> Looks like it is not exported from the package namespace... a >> packaging error. >> > > It's not an error to rely on the generic to get to a method. > > Duncan Murdoch
Well, then I will hedge by saying that IN MY OPINION it is an error, because when it isn't exported the arguments not specified in the generic cannot be visible for argument completion in editors. The predict.lm function specifies new data with the newdata argument, while the predict.bs function specifies it with the newx argument. Invoking with the generic is supposed be useful when trying out a variety of models, but being unable to generically specify a data frame (due to the inconsistent naming) blows that strategy to pieces anyway so you might as well be able to call the functions explicitly. -- Sent from my phone. Please excuse my brevity. On May 29, 2017 2:43:22 AM PDT, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> >On May 28, 2017 1:53:29 PM PDT, Rui Barradas <ruipbarradas at sapo.pt> >wrote: >> > predict.bs(SCurve, xnew = 40:45) >> Error in predict.bs(SCurve, xnew = 40:45) : >> could not find function "predict.bs" > >You should call it using the generic, i.e. > >predict(SCurve, xnew = 40:45) > > >On 29/05/2017 2:35 AM, Jeff Newmiller wrote: >> Looks like it is not exported from the package namespace... a >packaging error. >> > >It's not an error to rely on the generic to get to a method. > >Duncan Murdoch
On 29/05/2017 3:15 PM, Jeff Newmiller wrote:> Well, then I will hedge by saying that IN MY OPINION it is an error, because when it isn't exported the arguments not specified in the generic cannot be visible for argument completion in editors.But that's not true. If you want the arguments , use args(getS3method("predict", class(x))) where x is your bs() object. RStudio appears to make use of something like this. R.app on MacOS and Rgui on Windows does something different, I think not as effectively. I don't know about other editors. (BTW, I think the getS3method function has a bug: if you change the x object to have class c("foobar", class(x)), it *does* fail, even though predict(x, ...) will still work.) The predict.lm function specifies new data with the newdata argument, while the predict.bs function specifies it with the newx argument. Invoking with the generic is supposed be useful when trying out a variety of models, but being unable to generically specify a data frame (due to the inconsistent naming) blows that strategy to pieces anyway so you might as well be able to call the functions explicitly.>In RStudio, if you set x <- bs(1:10), then type predict(x, and hit TAB, you are offered "object", "newx" and "..." as choices. On the other editors I mentioned you appear to get a list of argument names for all possible methods regardless of the class of x. Duncan murdoch