[R] Frequencies from x/y data into a 2d table (for 3d histogram or heatmap)

Ralf B ralf.bierig at gmail.com
Thu Mar 25 22:03:51 CET 2010


Hi all,

I have simple x/y data from screen recording in a sequence:

number,x,y
----------------
1,10,30
1,20,
1,43,110
1,74,18
1,88,112

and would like to create a 3d histogram data structure that i can use
to create a 3d histogram or, more likely a heatmap. The unterlying
data structure therefore needs to look like this:

          0-10        11-20         21-30        31-40
0-10
11-20
21-30
31-40

where the values in the cells represent counts of datapoints fitting
respective ranges for x and y. Can somebody point me to a procedure in
R that can make such a transformation for different range sizes (i.e.
10 in my example)? I came across the following method:

https://stat.ethz.ch/pipermail/r-help/attachments/20070425/fcb92205/attachment.pl


which seems (at least close) but did not get it running (could not
find clear3d()). I also dont' need the 3d histogram plot as I will be
using the table to create a heatmap. I might be thinking to
complicated here. To me, it seems like this should be possible with a
few lines of code. Perhaps one of you has them lying around somewhere
or knows a script that does the trick.

Thanks in advance!

Ralf



More information about the R-help mailing list