likertWeighted47: Special case wrapper for likert() when multiple columns are...

View source: R/likertWeighted47.R

likertWeighted47R Documentation

Special case wrapper for likert() when multiple columns are to have the same bar thicknesses. Uses formula.

Description

Special case wrapper for likert() when multiple columns are to have the same bar thicknesses. Uses formula. Each row of the data is placed in its own trellis panel. Optionally, adjacent panels can be grouped in a common border. likertWeighted47() was introduced in HH_3.1-47 with the name likertWeighted(), and is now deprecated in favor of a redesigned likertWeighted(). All examples in likertWeighted47() work unchanged with likertWeighted(), although with slightly different appearance. The likertWeighted47() appearance can be produced with adjusted arguments in the new likertWeighted().

Usage

likertWeighted47(x, data, xlim=c(-100,100),
                   x.at=seq(-100,100,25), x.labels=abs(x.at),
                   h.resizePanels=data$rowheights,
                   rightAxisLabels=format(round(h.resizePanels, digits),
                                          big.mark=","),
                   ylab=NULL,
                   axis.key.padding=10,
                   y.tck=c(0,3),
                   layout=c(1, nrow(data)),
                   as.percent=TRUE,
                   line.color="black",
                   box.ratio=1000,
                   digits=-3,
                   scales.cex=1,
                   between=list(y=0),
                   layer=TRUE,
                   ...)

Arguments

x

a formula of the form ~ a + b + c | panelnames where a, b, c are columns in data and panelnames is a column of data that will normally be a copy of rownames(data). The values in panelnames must be unique. The formula ~ . | panelnames where . stands for the '+' of all variables in the data.frame other than panel.names may be used.

This formula will be passed to likert

data

data.frame

x.at, x.labels

location of x tick-marks and value of corresponding labels. Same meaning as scales=list(x=list(at=seq(-100,100,25), labels=abs(seq(-100,100,25))))

between

Standard argument to lattice functions, see xyplot. In addition, adjacent panels with zero-valued y.between between them will be grouped within the same borders, and adjacent panels with non-zero-valued y.between between them will be be in separately bordered groups. See example EEE.

xlim, ylab, layout, box.ratio

Standard arguments to lattice functions, see xyplot.

digits

See round

axis.key.padding

See trellis.par.get

as.percent, rightAxisLabels, h.resizePanels

See likert

scales.cex

Abbreviation for scales=list(cex=scales.cex)

y.tck

Abbreviation for scales=list(y=list(tck=y.tck)

line.color

Color to be used to surround sub-panels when between=list(y=v) has a non-zero vector for v.

layer

Logical, default TRUE. If TRUE then put a border around the sets of grouped panels. If FALSE, then don't put a border.

...

additional arguments that will be passed through to likert and from there to lattice.

Details

In the standard likert() plot, all stacked bars have the same thickness. The likertWeighted47 function weights the thickness of the bars by h.resizePanels. When used with as.percent=TRUE, the i^th stacked bar is 100% wide and h.resizePanels[i] units high. As a consequence one square inch of plotting surface represents the same number of objects in all bars and sub-bars. Compare AAA, BBB, and CCC in the examples to see the effect.

Value

A "trellis" object containing the plot. The plot will be automatically displayed unless the result is assigned to an object.

Author(s)

Richard M. Heiberger, with contributions from Naomi B. Robbins <naomi@nbr-graphs.com>.

Maintainer: Richard M. Heiberger <rmh@temple.edu>

See Also

likert

Examples


tmp <- data.frame(matrix(1:12, 3, 4,
                           dimnames=list(c("A","B","C"),
                                         c(letters[4:7]))))
tmpcc <- cbind(tmp, rowheights=rowSums(tmp))

AAA <- likert(~ . , data=tmp, rightAxisLabels=tmpcc$rowheights,
              main="The total width of each bar is the sum of its magnitudes.
The width of each sub-bar is its magnitude.
All bars have the same thickness.")
AAA

BBB <- likert(~ . , data=tmp, as.percent=TRUE, rightAxisLabels=tmpcc$rowheights,
              main="The total width of each bar is 100
The width of each sub-bar is its proportion of its row.
All bars have the same thickness.")
BBB

CCC <- likertWeighted47(~ . | rowheights, tmpcc,
                          as.percent=TRUE, xlim=c(-100,100),
                          rightAxisLabels=tmpcc$rowheights,
                          main="The total width of each bar is 100
The width of each sub-bar is its proportion of its row.
The thickness of each bar is the unique sum of its magnitudes.")
CCC



tmpdd <- cbind(tmp, rownames=row.names(tmp))

likertWeighted47(~ . | rownames, tmpdd,
                   as.percent=TRUE, xlim=c(-100,100),
                   rightAxisLabels=tmpcc$rowheights,
                   main="Equal row thicknesses")

likertWeighted47(~ . | rownames, tmpdd,
                   as.percent=TRUE, xlim=c(-100,100),
                   rightAxisLabels=tmpcc$rowheights,
                   h.resizePanels=rowSums(tmp),
                   main="Variable row thicknesses")

likertWeighted47(~ . | rownames, tmpdd,
                   as.percent=TRUE, xlim=c(-100,100),
                   rightAxisLabels=c(1,3,3),
                   h.resizePanels=c(1,3,3),
                   ylab.right="Thicknesses Explicitly Specified",
                   main="Variable row thicknesses, with some duplication")

DDD <-
likertWeighted47(~ . | rownames, tmpdd,
                   as.percent=TRUE, xlim=c(-100,100),
                   rightAxisLabels=paste(tmpcc$rowheights, c(1,3,3), sep=", "),
                   ylab.right="RowCount Total\nThicknesses Explicitly Specified",
                   h.resizePanels=c(1,3,3),
                   main="The total width of each bar is 100
The width of each sub-bar is its proportion of its row.
The thickness of each bar is the value of h.resizePanels.")
DDD

## comparisons
AAA
BBB
CCC
DDD

EEE <-
likertWeighted47(~ . | rownames, tmpdd,
                   as.percent=TRUE, xlim=c(-100,100),
                   h.resizePanels=rowSums(tmp),
                   rightAxisLabels=rowSums(tmp),
                   between=list(y=c(0,1)),
                   ylab=c("C in its own group","A and B together"),
                   main="Illustrating between: between=list(y=c(0,1))
Adjacent A and B with y.between = 0 are in the same bordered group.
Adjacent B and C with y.between != 0 are in different bordered groups.")
EEE


HH documentation built on Aug. 9, 2022, 5:08 p.m.

Related to likertWeighted47 in HH...