[R] Unexplained behaviour of .Last.value

Bickis, Mikelis b|ck|@ @end|ng |rom m@th@u@@@k@c@
Sat Jun 19 00:17:16 CEST 2021


Hello:

Here is a bit of R-code:

> mvr
[1] 2.2658
> (sin(.Last.value)+sin(2*.Last.value))
[1] -0.2156507
> acos((-sqrt(17)-1)/8)
[1] 2.2658
> (sin(.Last.value)+sin(2*.Last.value))
[1] 1.76745
> (sin(mvr)+sin(2*mvr))
[1] -0.2156507
>

Note that my variable mvr is the value of acos((-sqrt(17)-1)/8).   However, if I use .Last.value after invoking the acos function in a further calculation, I get a nonsensical result.   What is going on?

I am running R version 4.0.0 (2020-04-24) on an iMac, operating system MacOS 11.4 “Big Sur”.

Mik Bickis


More information about the R-help mailing list