View source: R/likertWeighted47.R
likertWeighted47 | R Documentation |
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().
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, ...)
x |
a formula of the form This formula will be
passed to |
data |
|
x.at, x.labels |
location of x tick-marks and value of
corresponding labels.
Same meaning as |
between |
Standard argument to lattice functions, see
|
xlim, ylab, layout, box.ratio |
Standard arguments to lattice functions, see |
digits |
See |
axis.key.padding |
See |
as.percent, rightAxisLabels, h.resizePanels |
See |
scales.cex |
Abbreviation for |
y.tck |
Abbreviation for |
line.color |
Color to be used to surround sub-panels when
|
layer |
Logical, default |
... |
additional arguments that will be passed through to
|
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.
A "trellis"
object containing the plot. The plot will be
automatically displayed unless the result is assigned to an object.
Richard M. Heiberger, with contributions from Naomi B. Robbins <naomi@nbr-graphs.com>.
Maintainer: Richard M. Heiberger <rmh@temple.edu>
likert
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.