Re: [R] hex format

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Fri 08 Apr 2005 - 16:51:12 EST

>>>>> "David" == David Forrest <drf5n@maplepark.com> >>>>> on Thu, 7 Apr 2005 16:19:33 -0500 (CDT) writes:

....

    David> I think R has the hex to decimal OK, but might be     David> lacking in the decimal to hex case

    David> zz<-function(x){ x<-as.numeric(sub("#",'0x',x));     David> c(x%/%256^2, x%/%256%%256, x%%256) }

>> zz('#0f0e0d')

    David> [1] 15 14 13
>> zz('#ff0080')

    David> [1] 255 0 128

I think you have overlooked the col2rgb() function which does this (and more).

    David> If you already have the 3 byte triplet in read in as
    David> a binary, the same integer arithmetic does the
    David> extraction.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Apr 08 16:55:10 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:05 EST