[R] simple, unidimensional heat map

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Tue May 22 22:23:51 CEST 2012


Thanks a lot, Sarah!
Dimitri

On Mon, May 21, 2012 at 5:23 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
> Hi Dmitri,
>
> On Mon, May 21, 2012 at 5:06 PM, Dimitri Liakhovitski
> <dimitri.liakhovitski at gmail.com> wrote:
>> I was wondering if someone could point in the direction of a package
>> that could generate not heatmaps, but something like a unidimensional
>> heat map.
>> I might be mistaken, but it seems like image and heatmap are an
>> overkill for such a simple task.
>
> You don't have to use all the options. Why not use something like
> image that does the heavy lifting for you?
>
>> For example, if I have a data frame:
>> x<-data.frame(myname=paste("value",1:10,sep=""),a=1:10,b=sample(1:10,10,replace=T))
>>
>> I'd like to create a chart (it's more of a table, actually) with one
>> horizontal axis ("myname") and 2 rows of rectangles above it - one for
>> "a" and one for "b". Such that the higher the value, the more intense
>> the color of the rectangle (10 rectangles for 10 values).
>
> Here's one approach:
>
>
> image(as.matrix(x[,2:3]), xaxt="n", yaxt="n")
> axis(1, seq(0, 1, length=10), x[,1])
> axis(2, c(0, 1), colnames(x)[2:3])
>
> Sarah
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org



-- 
Dimitri Liakhovitski
marketfusionanalytics.com



More information about the R-help mailing list