ToBW.likert: Change colors in a likert plot to shades of Black and White.

View source: R/ToBW.likert.R

ToBW.likertR Documentation

Change colors in a likert plot to shades of Black and White.

Description

Change colors in a likert plot to shades of Black and White. This function is tailored for a likert plot, an example of a "trellis" object. likert is based on panel.bwplot. There are other places in the structure of a more general "trellis" object where colors are stored. The specifics for this plot is (1) that the colors for negative values in the plot are in reverse order and (2) the color for a neutral-position panel appears on both the positive and negative side. The default values are for three items on the negative side, two on the positive side, and no neutral. See the examples for an example with a neutral.

Usage

   ToBW.likert(x,
               colLegendOrder=c("gray70", "gray20", "gray60", "gray75", "gray45"),
##                               ^Ask      Refu      ^Imp    | Impt      Essn
##	       
               colBarchartOrder=colLegendOrder[c(3,2,1,4,5)],
##                               ^Imp      Refu      ^Ask    | Impt      Essn
               columns=5)
## negative colors are in reverse order in the BarchartOrder

Arguments

x

"trellis" object, specifically one constructed by the likert function.

colLegendOrder

Revised value of x$legend$bottom$args$rect$col

colBarchartOrder

Revised value of both x$panel.args.common$col x$panel.args.common$border.

columns

Revised value of x$legend$bottom$args$columns

Value

"trellis" object, identical to the input object except for the colors.

Author(s)

Richard M. Heiberger <rmh@temple.edu>

See Also

likert

Examples

tmp <- array(1:20, c(4, 5),
             list(letters[1:4],
                  c("NotAsked","VeryNegative","Negative","Positive","VeryPositive")))
tmp

Ltmp <- likert(tmp, ReferenceZero=3.5, col=c("gray85", likertColor(4)), as.percent=TRUE)
Ltmp

ToBW.likert(Ltmp)

## with neutral

tmp2 <- array(1:20, c(4, 5),
             list(letters[1:4],
                  c("VeryNegative","Negative","Neutral","Positive","VeryPositive")))
tmp2

Ltmp2 <- likert(tmp2, ReferenceZero=3, col=likertColor(5),
                as.percent=TRUE, main="Neutral")
Ltmp2

ToBW.likert(Ltmp2, 
            colLegendOrder=c("gray20", "gray60", "gray85", "gray75", "gray45"),
##                                               Neu|tral 
            colBarchartOrder=c("gray85", "gray60", "gray20",  "gray85", "gray75", "gray45")
##                         Neutral left                        Neutral right
)

update(main="Wrong way to handle neutral",
       ToBW.likert(Ltmp2, 
                   colLegendOrder=c("gray20", "gray60", "gray85", "gray75", "gray45"))
      )


HH documentation built on May 29, 2024, 6:24 a.m.

Related to ToBW.likert in HH...