[R] converting hexadecimal

Duncan Murdoch murdoch at stats.uwo.ca
Wed May 24 17:23:39 CEST 2006

On 5/24/2006 11:01 AM, Romain Lorrilliere wrote:
> Hi,
> do you know, a method to convert an hexadecimal value to the 
> corresponding integer value (decimal) ?

as.double (which is called by as.numeric) automatically converts hex to 
numeric values.  You need to make sure the hex strings have a "0x" 
prefix, e.g.

 > as.numeric("0x0A")
[1] 10

You can use paste() or gsub() to put the prefix on existing strings.

Duncan Murdoch

More information about the R-help mailing list