[R] Color cells of a matrix as in Excel

jim holtman jholtman at gmail.com
Wed Feb 15 00:45:04 CET 2012

Check out the XLConnect package for formatting a spreadsheet.

On Tue, Feb 14, 2012 at 5:21 PM, John Nicholas <jbnichola at gmail.com> wrote:
> All,
> I frequently make spreadsheets in Excel in which I rank values in columns
> by stop-light colors (red is bad, yellow is OK, green is good).
> Image and heatmap expect a matrix in which all the data are in the same
> scale, but I frequently have different scales in different columns. ie.
> Column one runs from 1-10 while column 2 runs from 1-100. I thus need to
> define a separate color ramp for each column. In addition, sometimes the
> smaller numbers are colored green, while sometimes the larger numbers are
> preferred and colored green. I also want to print in each cell the numeric
> value, and I need to show row names. A crude example without the color:
> RowNames        Col1     Col2
> ----------------------------------------------
> Row1                   1          1
> Row2                   5         50
> Row3                  7.5       80
> Row4                  10        99
> ......
> Is there any R package that can do something similar? Can I create a plot
> that is a matrix of rectangles and get color and text that way?
> Any help is greatly appreciated.
> Thanks,
> John
>        [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

More information about the R-help mailing list