[R] re-arranging data to create an image (or heatmap)

pierz s.piersma at gmail.com
Mon Feb 28 15:21:44 CET 2011


Let me start by introducing myself as a biologist with only a little
knowledge about programming in matlab and R. In the past I have succesfully
created my figures in matlab using the hist3d command, but I have not access
to matlab right now and would like to switch to R.

I have used the plot command to create a figure of my data and it does
almost what I want it to do.

My data matrix looks like this (these are the first few lines from it,
copied from R console):

         Time Abs
   [1,]  0.09714286                24
   [2,]  0.19428571                24
   [3,]  0.19428571                24
   [4,]  0.29142857                24
   [5,]  0.38857143                23
   [6,]  0.38857143                22
   [7,]  0.48571429                23
   [8,]  0.58285714                21
   [9,]  0.58285714                21
  [10,]  0.68000000                23
  [11,]  0.68000000                25
  [12,]  0.68000000                23
  [13,]  0.77714286                23
  [14,]  0.77714286                23
  [15,]  0.87428571                21
  [16,]  0.87428571                20
  [17,]  0.87428571                22
  [18,]  1.06857143                23
  [19,]  1.06857143                25

The example shows that some of the plotted points appear more than once. I
would like to use a heatmap to show that these points have more weight, but
I have difficulty arranging the data to be plotted correctly using the
image() or heatmap() command.

So what I would want to do is to get the same figure as when I use the plot
command, but have colors representing the weight of the plotted points
(wether they occur once, twice or multiple times).

I have tried searching this forum and also used google, but I seem to keep
going in circles. I think that the image() command fits my needs, but that
my input data is not in the correct format.

Attached I have an image example from R and an image example from matlab.
This is how far I got using R:
http://r.789695.n4.nabble.com/file/n3327986/example_R.jpg 

This is the result I am aiming for:
http://r.789695.n4.nabble.com/file/n3327986/example_matlab.jpg 


-- 
View this message in context: http://r.789695.n4.nabble.com/re-arranging-data-to-create-an-image-or-heatmap-tp3327986p3327986.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list