[Rd] [External] numericDeriv alters result of eval in R 4.0.1
iuke-tier@ey m@iii@g oii uiow@@edu
iuke-tier@ey m@iii@g oii uiow@@edu
Tue Jun 16 16:30:58 CEST 2020
Thanks; definitely a bug. I've submitted it to the bug tracker at
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17831
Best,
luke
On Mon, 15 Jun 2020, Raimundo Neto wrote:
> Dear R developers,
>
> I've run into a weird behavior of the numericDeriv function (from the stats
> package) which I also posted on StackOverflow (question has same title as
> this email, except for the version of R).
>
> Running the code bellow we can see that the numericDeriv function gives an
> error as the derivative of x^a wrt a is x^a * log(x) and log is not defined
> for negative numbers. However, seems like the function changes the value of
> env1$a from 3 to 3.000000044703483581543. If x is a vector of positive
> values numericDeriv function completes the task without errors and env1$a
> remains unchanged as expected.
>
> This happened to me running R 4.0.1 on Ubuntu 20.04 and also to another
> StackOverflow user using running the same version of R on Windows 10. I
> wonder, is this an intended behavior of the function or really a bug?
>
> options(digits=22)
> env1 = new.env()
> env1$x = rnorm(10)
> env1$a = 3
> eval(quote(x^a), env1)
> numericDeriv(quote(x^a), "a", env1)
> eval(quote(x^a), env1)
> env1$a
>
> Thank you!
> Raimundo Neto
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa Phone: 319-335-3386
Department of Statistics and Fax: 319-335-3017
Actuarial Science
241 Schaeffer Hall email: luke-tierney using uiowa.edu
Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
More information about the R-devel
mailing list