[R] Assigning colors to cells
Dennis Murphy
djmuser at gmail.com
Wed Jul 20 01:49:30 CEST 2011
Use the cut() function to produce the interval categories and color
names in the data frame and then pass that variable to the col =
argument in the appropriate plot function. Something like
mydata$mycolors <- cut(mydata$value, c(-Inf, 1, 2, 3, Inf), label =
c('blue', 'green', 'yellow'))
Ask an abstract question, get an abstract answer...
HTH,
Dennis
On Tue, Jul 19, 2011 at 2:30 PM, Sumukh Sathnur
<sumukh.sathnur at gmail.com> wrote:
> Hi everyone,
>
> I was wondering if there was a simple way to assign a color to a cell based
> on value in a data frame and return the cell as an image? For example, if
> the value is >1, then blue, if between 1 and 2, green, if between 2 and 3,
> yellow, etc.
>
> I tried using a heatmap function but I was hoping there was an easier way to
> do this.
>
> Thanks,
> Sumukh
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list