Setzer.Woodrow@epamail.epa.gov
2001-Jul-31 15:47 UTC
[Rd] nlme: bug in getCovariateFormula (PR#1038)
I found that predict.gnls failed with a wierd error message about a
non-numeric argument to a binary vector in one of three nearly identical
uses.
Error in Inh/Ki : non-numeric argument to binary operator
(Inh and Ki are arguments to the function used in the formula for the
object whose predictions were requested).
It turns out that the problem is in getCovariateFormula().
The final line in getCovariateFormula() in the nlme package (version
3.1-16) is:
eval(parse(text = paste("~", deparse(form))))
however, if deparse(form) exceeds 'width.cutoff (which defaults to 60)',
this results in inappropriately placed "~" signs:
For example, in my application with the error, form is
UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km, Ki)
the result of the paste() operation in the last line of getCovariateFormula
is:
> paste("~",deparse(form))
[1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km, "
[2] "~ Ki)"
extending width.cutoff gives the intended value:
> paste("~",deparse(form,width.cutoff=500))
[1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km,
Ki)"
Seems a bit risky for an enforced cutoff in deparse, though.
R. Woodrow Setzer, Jr. Phone:
(919) 541-0128
Experimental Toxicology Division Fax: (919) 541-5394
Pharmacokinetics Branch
NHEERL MD-74; US EPA; RTP, NC 27711
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Setzer.Woodrow@epamail.epa.gov writes:> The final line in getCovariateFormula() in the nlme package (version > 3.1-16) is: > eval(parse(text = paste("~", deparse(form)))) > > however, if deparse(form) exceeds 'width.cutoff (which defaults to 60)', > this results in inappropriately placed "~" signs: > For example, in my application with the error, form is > > UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km, Ki) > > the result of the paste() operation in the last line of getCovariateFormula > is: > > > paste("~",deparse(form)) > [1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km, " > [2] "~ Ki)" > > extending width.cutoff gives the intended value: > > > paste("~",deparse(form,width.cutoff=500)) > [1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km, Ki)" > > Seems a bit risky for an enforced cutoff in deparse, though.parse(...deparse(...)) always looks wrong to me anyway. Couldn't one use something like f <- ~1 f[[2]] <- form eval(f) or eval(as.call(list(as.name("~"),form))) or eval(substitute(~form)) # that's not going to work in S, though... ?? (What is the eval for? Doesn't usually do anything to a formula argument.) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Setzer.Woodrow@epamail.epa.gov
2001-Jul-31 20:10 UTC
[Rd] nlme: bug in getCovariateFormula (PR#1038)
It looks clunky, but you could maintain consistency across S and R forms
with
eval(parse(text=paste("~",paste(deparse(form),collapse="
"))))
R. Woodrow Setzer, Jr. Phone:
(919) 541-0128
Experimental Toxicology Division Fax: (919) 541-5394
Pharmacokinetics Branch
NHEERL MD-74; US EPA; RTP, NC 27711
Douglas Bates
<bates@stat.wis To: Peter Dalgaard BSA
<p.dalgaard@biostat.ku.dk>
c.edu> cc: Woodrow
Setzer/RTP/USEPA/US@EPA, r-devel@stat.math.ethz.ch,
Sent by: R-bugs@biostat.ku.dk
bates@franz.sta Subject: Re: [Rd] nlme: bug in
getCovariateFormula (PR#1038)
t.wisc.edu
07/31/01 02:55
PM
Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:
> Setzer.Woodrow@epamail.epa.gov writes:
>
> > The final line in getCovariateFormula() in the nlme package (version
> > 3.1-16) is:
> > eval(parse(text = paste("~", deparse(form))))
> >
> > however, if deparse(form) exceeds 'width.cutoff (which defaults to
60)',> > this results in inappropriately placed "~" signs:
> > For example, in my application with the error, form is
> >
> > UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km, Ki)
> >
> > the result of the paste() operation in the last line of
getCovariateFormula> > is:
> >
> > > paste("~",deparse(form))
> > [1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax,
Km, "
> > [2] "~ Ki)"
> >
> > extending width.cutoff gives the intended value:
> >
> > > paste("~",deparse(form,width.cutoff=500))
> > [1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax,
Km,
Ki)"> >
> > Seems a bit risky for an enforced cutoff in deparse, though.
>
> parse(...deparse(...)) always looks wrong to me anyway. Couldn't one
> use something like
>
> f <- ~1
> f[[2]] <- form
> eval(f)
>
> or
>
> eval(as.call(list(as.name("~"),form)))
> or
>
> eval(substitute(~form)) # that's not going to work in S, though...
Exactly. The code was originally written for S and ported to R. Some
of the contorted expressions were things that we found by
experimentation would work in both systems.
> ??
>
> (What is the eval for? Doesn't usually do anything to a
> formula argument.)
In Sv3 at least it assigns a class to the object.
I'll change it to eval(substitute(~form)) for the R package.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Setzer.Woodrow@epamail.epa.gov
2001-Jul-31 20:19 UTC
[Rd] nlme: bug in getCovariateFormula (PR#1038)
It looks clunky, but you could maintain consistency across S and R forms
with
eval(parse(text=paste("~",paste(deparse(form),collapse="
"))))
R. Woodrow Setzer, Jr. Phone:
(919) 541-0128
Experimental Toxicology Division Fax: (919) 541-5394
Pharmacokinetics Branch
NHEERL MD-74; US EPA; RTP, NC 27711
Douglas Bates
<bates@stat.wis To: Peter Dalgaard BSA
<p.dalgaard@biostat.ku.dk>
c.edu> cc: Woodrow
Setzer/RTP/USEPA/US@EPA, r-devel@stat.math.ethz.ch,
Sent by: R-bugs@biostat.ku.dk
bates@franz.sta Subject: Re: [Rd] nlme: bug in
getCovariateFormula (PR#1038)
t.wisc.edu
07/31/01 02:55
PM
Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:
> Setzer.Woodrow@epamail.epa.gov writes:
>
> > The final line in getCovariateFormula() in the nlme package (version
> > 3.1-16) is:
> > eval(parse(text = paste("~", deparse(form))))
> >
> > however, if deparse(form) exceeds 'width.cutoff (which defaults to
60)',> > this results in inappropriately placed "~" signs:
> > For example, in my application with the error, form is
> >
> > UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax, Km, Ki)
> >
> > the result of the paste() operation in the last line of
getCovariateFormula> > is:
> >
> > > paste("~",deparse(form))
> > [1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax,
Km, "
> > [2] "~ Ki)"
> >
> > extending width.cutoff gives the intended value:
> >
> > > paste("~",deparse(form,width.cutoff=500))
> > [1] "~ UnCompetitive(MethoxyresorufinConc, InhibitorConc, Vmax,
Km,
Ki)"> >
> > Seems a bit risky for an enforced cutoff in deparse, though.
>
> parse(...deparse(...)) always looks wrong to me anyway. Couldn't one
> use something like
>
> f <- ~1
> f[[2]] <- form
> eval(f)
>
> or
>
> eval(as.call(list(as.name("~"),form)))
> or
>
> eval(substitute(~form)) # that's not going to work in S, though...
Exactly. The code was originally written for S and ported to R. Some
of the contorted expressions were things that we found by
experimentation would work in both systems.
> ??
>
> (What is the eval for? Doesn't usually do anything to a
> formula argument.)
In Sv3 at least it assigns a class to the object.
I'll change it to eval(substitute(~form)) for the R package.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
p.dalgaard@biostat.ku.dk
2001-Jul-31 21:16 UTC
[Rd] nlme: bug in getCovariateFormula (PR#1038)
Douglas Bates <bates@stat.wisc.edu> writes:> Exactly. The code was originally written for S and ported to R. Some > of the contorted expressions were things that we found by > experimentation would work in both systems. > > > ?? > > > > (What is the eval for? Doesn't usually do anything to a > > formula argument.) > > In Sv3 at least it assigns a class to the object.Aha. In R too.> I'll change it to eval(substitute(~form)) for the R package.Great. I would have thought that one of the two other forms would be portable, though. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._