[R] creating a color display matrix

Kartik Pappu kpappu at mednet.ucla.edu
Wed Jul 26 22:30:07 CEST 2006


Hello all,

I am trying to use R to create a colored data matrix.  I have my data 
which (after certain steps of normalization and log transformation) 
gives me a "x by y" matrix of numbers between 0 and -5.  I want to be 
able to create from this matrix of numbers a "x by y" image (box) that 
contains x*y squares and somehow uses the value in the original matrix 
to come up with a color that corresponds to the number.  Hence each box 
will be colored on a scale between 0 and 5.  For example my data could 
look like this:

                 X1.FcH      X2.FcH      X3.FcH     X4.FcH      X5.FcH   
  X6.FcH       X7.FcH
1-AP        0.09667593 -4.66298640 -1.28299697 -4.8739017 -4.95862831 
-5.178603 -4.878524750
2-AP       -4.69186869 -0.08547776 -4.56495440 -4.8348255 -4.80256152 
-5.121531 -4.894347108
3-AP       -1.71380667 -4.52626124 -0.06810053 -4.8703810 -4.65657593 
-5.024595 -4.824712621
4-AP       -4.47968850 -4.48604718 -4.44314403 -0.1569536 -4.86436977 
-4.988196 -4.550416356
5-AP       -4.64616469 -4.53888807 -4.78163386 -4.9162949 -0.01729274 
-5.061663 -0.769960777
6-AP       -4.61047573 -4.60917414 -4.72514817 -5.0084772 -4.87797740 
-0.284934 -1.782745357
7-AP       -4.48157167 -4.61850313 -4.72241281 -4.8694868 -1.66122821 
-3.887898 -0.002522157

How do I make a 7 x 7 box that has 49 squares and each square has a 
color in the RGB spectrum that corresponds to the value.  So for 
example in the matrix above the biggest number which is 0.00966 (at 
position 1 , 1) could be set to RED and the smallest number which is 
5.0084 (at position 6, 5) can be set to BLUE and all the other numbers 
be shades on a scale of Red going to Blue.

I hope this problem makes sense.  I am rather new to R and was 
wondering if there was a function or solution to this problem out 
there.

Thanks
Kartik


----------------------------------------------------------
IMPORTANT WARNING:  This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential.  You, the recipient, are obligated to maintain it in a safe, secure and confidential manner.  Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the recipient, please immediately notify us by return email, and delete this message from your computer.



More information about the R-help mailing list