Re: [R] get the value of a biplane

2017-05-29 Thread David Winsemius

> On May 29, 2017, at 1:16 PM, Duncan Murdoch  wrote:
> 
> 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 think R.app uses rcompgen {utils}. Fortunately a deficit in my aging memory 
was filled in because typing `?completion` brought up the correct help page. I 
was not so lucky in trying to find reference to that function in the R for 
MacOS FAQ.

-- 
David.
> 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
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] get the value of a biplane

2017-05-29 Thread 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

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] get the value of a biplane

2017-05-29 Thread Jeff Newmiller
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  wrote:
>
>On May 28, 2017 1:53:29 PM PDT, Rui Barradas 
>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

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] get the value of a biplane

2017-05-29 Thread Rui Barradas

Hello,

Em 29-05-2017 10:43, Duncan Murdoch escreveu:


On May 28, 2017 1:53:29 PM PDT, Rui Barradas  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


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] get the value of a biplane

2017-05-29 Thread Duncan Murdoch


On May 28, 2017 1:53:29 PM PDT, Rui Barradas  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

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] get the value of a biplane

2017-05-28 Thread Jeff Newmiller
Looks like it is not exported from the package namespace... a packaging error. 
-- 
Sent from my phone. Please excuse my brevity.

On May 28, 2017 1:53:29 PM PDT, Rui Barradas  wrote:
>Hello,
>
>Can anyone explain why this error?
>
> > library(splines)
> >
> > knots <- c(6, 12, 22, 30, 35)
> > x <- c(0.0, .25, 1.0, 2.0, 3.0)
>> SCurve <- bs(x = x, knots = knots, intercept = FALSE, Boundary.knots 
>= c(0,3.5))
> > class(SCurve)
>[1] "bs" "basis"  "matrix"
> >
> > ?predict.bs
> > predict.bs(SCurve, xnew = 40:45)
>Error in predict.bs(SCurve, xnew = 40:45) :
>   could not find function "predict.bs"
>
>Note that splines:::predict.bs(SCurve, xnew = 40:45) works.
>
> > sessionInfo()
>R version 3.4.0 (2017-04-21)
>Platform: x86_64-w64-mingw32/x64 (64-bit)
>Running under: Windows 7 x64 (build 7601) Service Pack 1
>
>Matrix products: default
>
>locale:
>[1] LC_COLLATE=Portuguese_Portugal.1252 
>LC_CTYPE=Portuguese_Portugal.1252
>[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C 
>
>[5] LC_TIME=Portuguese_Portugal.1252
>
>attached base packages:
>[1] splines   stats graphics  grDevices utils datasets  methods
>[8] base
>
>loaded via a namespace (and not attached):
>[1] compiler_3.4.0 tools_3.4.0
>
>
>Rui Barradas
>
>
>Em 28-05-2017 17:37, Rui Barradas escreveu:
>> Hello,
>>
>> Since function splines::bs returns an object of class bs in order to
>> read the help page for function predict you need
>>
>> ?predict.bs
>>
>> The syntax would be
>>
>> ## S3 method for class 'bs'
>> predict(object, newx, ...)
>>
>> Please read that help page and maybe you'll get the answer you need.
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>> Em 28-05-2017 15:51, Glenn Schultz escreveu:
>>> If is specify a spline basis as follows
>>>
>>> knots <- c(6, 12, 22, 30, 35)
>>> x <- c(0.0, .25, 1.0, 2.0, 3.0)
>>> SCurve <- bs(x = x, knots = knots, intercept = FALSE, Boundary.knots
>=
>>> c(0,3.5))
>>>
>>> I would like to now get the spline value for new values of x. 
>However,
>>> when I use predict the new basis is returned and I would like to get
>the
>>> value.  Nothing has worked so far and ?predict plus examples only
>show
>>> prediction from linear models.  Is there a way to extract the value
>from
>>> a defined spline?
>>>
>>> Best Regards,
>>> Glenn
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] get the value of a biplane

2017-05-28 Thread Rui Barradas

Hello,

Can anyone explain why this error?

> library(splines)
>
> knots <- c(6, 12, 22, 30, 35)
> x <- c(0.0, .25, 1.0, 2.0, 3.0)
> SCurve <- bs(x = x, knots = knots, intercept = FALSE, Boundary.knots 
= c(0,3.5))

> class(SCurve)
[1] "bs" "basis"  "matrix"
>
> ?predict.bs
> predict.bs(SCurve, xnew = 40:45)
Error in predict.bs(SCurve, xnew = 40:45) :
  could not find function "predict.bs"

Note that splines:::predict.bs(SCurve, xnew = 40:45) works.

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 
LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C 


[5] LC_TIME=Portuguese_Portugal.1252

attached base packages:
[1] splines   stats graphics  grDevices utils datasets  methods
[8] base

loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0


Rui Barradas


Em 28-05-2017 17:37, Rui Barradas escreveu:

Hello,

Since function splines::bs returns an object of class bs in order to
read the help page for function predict you need

?predict.bs

The syntax would be

## S3 method for class 'bs'
predict(object, newx, ...)

Please read that help page and maybe you'll get the answer you need.

Hope this helps,

Rui Barradas

Em 28-05-2017 15:51, Glenn Schultz escreveu:

If is specify a spline basis as follows

knots <- c(6, 12, 22, 30, 35)
x <- c(0.0, .25, 1.0, 2.0, 3.0)
SCurve <- bs(x = x, knots = knots, intercept = FALSE, Boundary.knots =
c(0,3.5))

I would like to now get the spline value for new values of x.  However,
when I use predict the new basis is returned and I would like to get the
value.  Nothing has worked so far and ?predict plus examples only show
prediction from linear models.  Is there a way to extract the value from
a defined spline?

Best Regards,
Glenn
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] get the value of a biplane

2017-05-28 Thread Rui Barradas

Hello,

Since function splines::bs returns an object of class bs in order to 
read the help page for function predict you need


?predict.bs

The syntax would be

## S3 method for class 'bs'
predict(object, newx, ...)

Please read that help page and maybe you'll get the answer you need.

Hope this helps,

Rui Barradas

Em 28-05-2017 15:51, Glenn Schultz escreveu:

If is specify a spline basis as follows

knots <- c(6, 12, 22, 30, 35)
x <- c(0.0, .25, 1.0, 2.0, 3.0)
SCurve <- bs(x = x, knots = knots, intercept = FALSE, Boundary.knots =
c(0,3.5))

I would like to now get the spline value for new values of x.  However,
when I use predict the new basis is returned and I would like to get the
value.  Nothing has worked so far and ?predict plus examples only show
prediction from linear models.  Is there a way to extract the value from
a defined spline?

Best Regards,
Glenn
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] get the value of a biplane

2017-05-28 Thread Glenn Schultz

If is specify a spline basis as follows

knots <- c(6, 12, 22, 30, 35)
x <- c(0.0, .25, 1.0, 2.0, 3.0)
SCurve <- bs(x = x, knots = knots, intercept = FALSE, Boundary.knots = c(0,3.5))

I would like to now get the spline value for new values of x.  However, when I 
use predict the new basis is returned and I would like to get the value.  
Nothing has worked so far and ?predict plus examples only show prediction from 
linear models.  Is there a way to extract the value from a defined spline?

Best Regards,
Glenn
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.