On Sun, 7 Nov 2021 13:11:10 -0500
Duncan Murdoch wrote:
> I've submitted a bug report and patch:
>
> https://bugs.r-project.org/show_bug.cgi?id=18232
Thanks Duncan. It's good to know that the anomaly wasn't just a result
of my doing something stupid.
cheers,
Rolf
--
Honorary Research Fe
I've submitted a bug report and patch:
https://bugs.r-project.org/show_bug.cgi?id=18232
Duncan Murdoch
On 07/11/2021 12:20 p.m., Duncan Murdoch wrote:
Here's how to construct a similar deparsing error:
# e1 and e2 are obviously different expressions
e1 <- quote(5 * if (TRUE) 2 else 3/4)
e2 <
Here's how to construct a similar deparsing error:
# e1 and e2 are obviously different expressions
e1 <- quote(5 * if (TRUE) 2 else 3/4)
e2 <- quote(5 * (if (TRUE) 2 else 3)/4)
# and they evaluate differently
eval(e1)
#> [1] 10
eval(e2)
#> [1] 2.5
# We can make an equivalent version of e2 by mes
On 06/11/2021 11:32 p.m., Deepayan Sarkar wrote:
On Sun, Nov 7, 2021 at 6:05 AM Rolf Turner wrote:
I have two functions which appear to differ only in their environments.
They look like:
d1
function (x, mean = 0, sd = 1, log = FALSE)
(((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean,
G'day Rolf,
On Sun, 7 Nov 2021 19:33:40 +1300
Rolf Turner wrote:
> library(Deriv)
> d1 <- Deriv(dnorm,"sd")
> source("d2.txt") # d2.txt is attached
>
> d1(1,0,3,TRUE) # [1] -0.2962963
> d2(1,0,3,TRUE) # [1] -0.889
Fascinating:
R> pryr::call_tree(body(d1))
R> pryr::call_tree(body(d2))
cle
On Sun, 7 Nov 2021 09:02:36 +0530
Deepayan Sarkar wrote:
> This sounds like a difference in precedence. The expression
>
> if (log) 1 else dnorm(x, mean, sd) / sd
>
> is apparently being interpreted differently as
>
> d1: (if (log) 1 else dnorm(x, mean, sd)) / sd
> d2: if (log) 1 else (dnorm(x
library(Deriv)
d1 <- Deriv(dnorm,"sd")
source("d2.txt") # d2.txt is attached
d1(1,0,3,TRUE) # [1] -0.2962963
d2(1,0,3,TRUE) # [1] -0.889
cheers,
Rolf
P.S.:
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix product
On Sun, Nov 7, 2021 at 6:05 AM Rolf Turner wrote:
>
>
> I have two functions which appear to differ only in their environments.
> They look like:
>
> > d1
> > function (x, mean = 0, sd = 1, log = FALSE)
> > (((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd
> >
>
> and
>
> > d2
> > f
In general, the search for symbols for a function Z in a package Y will span
only those namespaces that the package Y specifies. The search for symbols in a
function whose parent environment is the global environment will start there,
thereby opening the door to find masking versions of function
I have two functions which appear to differ only in their environments.
They look like:
> d1
> function (x, mean = 0, sd = 1, log = FALSE)
> (((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd
>
and
> d2
> function (x, mean = 0, sd = 1, log = FALSE)
> (((x - mean)/sd)^2 - 1) * i
10 matches
Mail list logo