I've just found an annoyance with the behaviour of %/% which, BTW,
violated the sacred rule that for all a, and non-zero b:

a = b * (a %/% b) + a %% b

Namely, that Inf %/% n is not Inf, but NaN.

Why is this so? It's an annoyance, because in expressions like:

big.vector.1[a, b, c] <- big.vector.2[a, b, c] %/% n

we must treat Inf and -Inf as exceptions, when a simple division does
not have these exceptions

BTW, I treated this exception the way Grace Hopper would be proud of, namely,
"it's easier to ask forgiveness than it is to get permission", but at
the cost of memory:

big.vector.1 <- big.vector.2
big.vector.1[a, b, c] <- big.vector.2[a, b, c] %/% n
tst <- is.nan(big.vector.1)
if (any(tst)) big.vector.1[tst] <- big.vector.2

Alberto Monteiro

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to