Skip to content
Prev 374533 / 398513 Next

NAs produced by integer overflow, but only some time ...

a) Numeric values may be either integers (signed 32 bit) or double precision (53 bit mantissa).

b) Double precision constants are numeric with no decoration (e.g. 61224). Integer constants have an L (e.g. 61224L).

c) 61224*61224 > 2^31-1 so that answer cannot fit into an integer.

d) Exponentiation is a floating point operation so the result of 61224L^2L is a floating point answer that CAN fit into the 53bit mantissa of a double precision value, so no overflow occurs.

e) Defining a function like yules.k1 and never showing how you called it does not constitute a reproducible example. To avoid such gaffes you can use the reprex package to confirm that the errors shown in your question are in fact reproducible.

f) On this mailing list, the fact that you are using RStudio is at best irrelevant, and at worst off-topic. If you don't see problems running your reproducible example from R in the terminal then the question probably belongs in the RStudio support forum. This is another reason to use the reprex package to check your reproducibility (this works even if you invoke it from RStudio).

g) Calling table on the result of table must be one of the more bizarre calculation sequences I have ever seen in R. I hope you are getting the answers you are expecting when you do use double precision numeric values. Also, using the prefix form of multiplication is unnecessarily obscure, and your use of the return function at the end of your function is redundant.
On May 8, 2018 7:54:26 PM PDT, "Stefan Th. Gries" <stgries at gmail.com> wrote: