In a longer script I have to multiply the length of a vector A (2614) with the numbers of rows of a dataframe B (1456000). If I do that directly with length(A) * nrow(B)
I get the message NAs produced by integer overflow
although there's no problem when I multiply the same numbers:
2614 * 1456000
[1] 3805984000
The only way to get the multiplication to work is round(length(A)) * nrow(B)
or length(A) * round(nrow(B))
. But the numbers produced by length
and nrow
must be integers anyhow! Moreover, I tested this with the following function suggested on the help page for the function is.integer...
is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) abs(x-round(x)) < tol
... and of course, they ARE integers. So why do I need the crutches "round" here? Very puzzling... Somebody has got an idea what's going on in the background?