Skip to content
Prev 8413 / 21312 Next

[Bioc-devel] [Rd] For integer vectors, `as(x, "numeric")` has no effect.

Somehow, the most obvious fixes are always back-incompatible these days.

The example intrigued me, so I looked into it a bit (should have been doing something else, but ....)

You're right that this is the proverbial thin-edge-of-the-wedge.

The problem is in setDataPart(), which will be called whenever a class extends one of the vector types.

It does
	as(value, dataClass)
The key point is that the third argument to as(), strict=TRUE by default.  So, yes, the change will cause all integer vectors to become double when the class extends "numeric".  Generally, strict=TRUE makes sense here and of course changing THAT would open up yet more incompatibilities.

For back compatibility, one would have to have some special code in setDataPart() for the case of integer/numeric.

John

(Historically, the original sin was probably not making a distinction between "numeric" as a virtual class and "double" as a type/class.)
On Dec 11, 2015, at 1:25 AM, Martin Maechler <maechler at stat.math.ethz.ch> wrote: