Skip to content
Prev 67247 / 398502 Next

hex format

On Thu, Apr 07, 2005 at 11:58:48AM -0500, Earl F. Glynn wrote:
I'd like to second this opinion. It just occasionally happens that data are
available in some variant of hex format, and I've had the impression that
getting such data into R is a bit less convenient than it could be.
In fact, the ANSI C function strtol already provides conversion to any
base between 2 and 36, so R's mathematical capabilities don't even need
to be invoked here.

An R function strtol(x, base), x being a character variable and base an
integer between 2 and 36, would probably add a bit of convenience. I've
never programmed that, though -- seems that I'm one of those to whom this
hasn't been important enough.

If it is done some day, I'd favour the strtol function over having as.numeric
interpret the (rather C-ish) 0x prefix. I wasn't aware that this currently
works on some platforms (and I'm glad it doesn't interpret the 0 prefix for
octal, as C does, making 007 legal and 008 not.  ;-)  )

Best regards, Jan