Last data update: 2014.03.03

R: Color the cells of a data frame according to 4 threshold...
coltableR Documentation

Color the cells of a data frame according to 4 threshold levels

Description

Return a colored display of a data frame according to 4 threshold levels.

Usage

coltable(matrice, col.mat = matrice,
    nbrow = nrow(matrice), nbcol = ncol(matrice), 
    level.lower = 0.05, col.lower = "mistyrose", 
    level.upper = 1.96, col.upper = "lightblue",
    cex = 0,nbdec = 4, main.title = NULL, level.lower2 = -1e10,
    col.lower2 = "red", level.upper2 = 1e10, 
    col.upper2 = "blue", novalue = FALSE)

Arguments

matrice

a data frame (or a matrix) with only quantitative variables

col.mat

a data frame (or a matrix) from which the cells of the matrice data frame are colored; by default, col.mat=matrice

nbrow

the number of rows to be displayed (by default, nrow(matrice))

nbcol

the number of columns to be displayed (by default, ncol(matrice))

level.lower

the threshold below which cells are colored in col.lower

col.lower

the color used for level.lower

level.upper

the threshold above which cells are colored in col.upper

col.upper

the color used for level.upper

cex

cf. function par in the graphics package

nbdec

the number of decimal places displayed

main.title

title of the graph(s)

level.lower2

the threshold below which cells are colored in col.lower2; this level should be less than level.lower

col.lower2

the color used for level.lower2

level.upper2

the threshold above which cells are colored in col.upper2; this level should be greater than level.upper

col.upper2

the color used for level.upper2

novalue

boolean, if TRUE the values are not written

Details

This function is very useful especially when there are a lot of values to check.

Author(s)

F Husson, S Le

Examples

## Example 1
data(chocolates)
resdecat<-decat(sensochoc, formul = "~Product+Panelist", firstvar = 5,
    graph = FALSE)
resaverage<-averagetable(sensochoc, formul = "~Product+Panelist", 
    firstvar = 5)
resaverage.sort = resaverage[rownames(magicsort(resdecat$tabT)),
    colnames(magicsort(resdecat$tabT))]
coltable(resaverage.sort, magicsort(resdecat$tabT), 
    level.lower = -1.96, level.upper = 1.96,
    main.title = "Average by chocolate")

## Example 3
## Not run: 
data(chocolates)
resperf<-paneliperf(sensochoc, 
    formul = "~Product+Panelist+Product:Panelist", 
    formul.j = "~Product", col.j = 1, firstvar = 5, lastvar = 12, 
    synthesis = FALSE, graph = FALSE)
resperfprob<-magicsort(resperf$prob.ind, method = "median")
coltable(resperfprob, level.lower = 0.05, level.upper = 1, 
    main.title = "P-value of the F-test (by panelist)")

resperfr2<-magicsort(resperf$r2.ind, method = "median", 
    ascending = FALSE)
coltable(resperfr2, level.lower = 0.00, level.upper = 0.85, 
    main.title = "Adjusted R-square (by panelist)")

## End(Not run)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SensoMineR)
Loading required package: FactoMineR
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SensoMineR/coltable.Rd_%03d_medium.png", width=480, height=480)
> ### Name: coltable
> ### Title: Color the cells of a data frame according to 4 threshold levels
> ### Aliases: coltable
> ### Keywords: color
> 
> ### ** Examples
> 
> ## Example 1
> data(chocolates)
> resdecat<-decat(sensochoc, formul = "~Product+Panelist", firstvar = 5,
+     graph = FALSE)
> resaverage<-averagetable(sensochoc, formul = "~Product+Panelist", 
+     firstvar = 5)
> resaverage.sort = resaverage[rownames(magicsort(resdecat$tabT)),
+     colnames(magicsort(resdecat$tabT))]
> coltable(resaverage.sort, magicsort(resdecat$tabT), 
+     level.lower = -1.96, level.upper = 1.96,
+     main.title = "Average by chocolate")
Error in dev.new() : no suitable unused file name for pdf()
Calls: coltable -> police -> dev.new
Execution halted