View source: R/likertWeighted.R
likertWeighted | R Documentation |
Special case wrapper for likert() when multiple columns are to have the same bar thicknesses. Uses formula with one or two conditioning variables.
likertWeighted(x, ...) ## generic
## S3 method for class 'array'
likertWeighted(x, ..., C = 1, Q = 3, R = 2) ## array
## Default S3 method:
likertWeighted(x, ...) ## matrix, table, data.frame
## S3 method for class 'formula'
likertWeighted(x, data,
xlim=c(-100, 100),
scales=list(y=list(relation="free", cex=1.3),
x=list(at=seq(-100, 100, 50),
labels=abs(seq(-100, 100, 50)), cex=.5)),
box.ratio=1000,
as.percent=TRUE, rightAxis=FALSE,
between=list(x=1, y=0),
strip=FALSE, strip.left=FALSE,
par.settings=list(clip=list(panel="off")),
h.resizePanels=1,
auto.key.title=NULL,
auto.key.columns=dim(data)[[2]] -
NumberOfConditioningVariables(formula), ## excludes conditioning variables
auto.key.cex=1.2,
auto.key.cex.title=1.2,
auto.key.lines.title=3,
ylab=NULL,
axis.top=dimnames(result)[[1]], ## Questions
axis.top.row=1,
...)
x |
For the default method, a matrix or data.frame or two-dimensional table. For the array method, a two- or-three-dimensional array. For the formula method, a formula. |
formula |
Standard trellis formula, usually |
data |
A |
C , R , Q |
Integers, one each of 1,2,3; positions of the three dimensions. Used in
|
xlim , between , strip , strip.left , par.settings , ylab |
See |
scales |
See |
box.ratio |
See |
as.percent , rightAxis , ... , h.resizePanels |
First see the formula method for |
auto.key.title , auto.key.columns , auto.key.cex , auto.key.cex.title , auto.key.lines.title |
Values which will be used in |
axis.top |
Label to be placed at |
axis.top.row |
Which rows will have |
A likert
plot as a "trellis"
object.
Richard M. Heiberger <rmh@temple.edu>
likert
## simplest 2D example
tmp <- matrix(1:12, 3, 4,
dimnames=list(c("A","B","C"),
c(letters[4:7]))) * c(1,2,3)
tmp
rowSums(tmp)
likertWeighted(tmp,
h.resizePanels=rowSums(tmp),
main="likertWeighted, simplest example,
defaults to Percent,
specified row thicknesses")
## Same example with explicit use of the formula method
## (default method does this for you).
tmpdd <- data.frame(tmp, row=row.names(tmp))
tmpdd
likertWeighted(~ . | row, tmpdd, ## tmpdd
h.resizePanels=rowSums(tmp), ## tmp
main="likertWeighted,
same example but with explicit formula method")
## show subgroups
likertWeighted(tmp,
h.resizePanels=rowSums(tmp),
between=list(y=c(0, 1)),
ylab=c("C in its own group","A and B together"),
main="between=list(y=c(0,1) ## standard lattice between argument
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.")
## simplest 3D example
## This is natural when multiple questions are asked of the
## same set of respondents in a survey.
## This example simulates that situation.
##
tmp3D <- abind::abind(h=tmp, i=tmp, j=tmp, along=3)
tmp3D[1,,"i"] <- tmp3D[1,c(4,2,1,3),"h"]
tmp3D[2,,"i"] <- tmp3D[2,c(2,4,3,1),"h"]
tmp3D[3,,"i"] <- tmp3D[3,c(4,1,2,3),"h"]
tmp3D[1,,"j"] <- tmp3D[1,c(4,3,2,1),"h"]
tmp3D[2,,"j"] <- tmp3D[2,c(1,4,3,2),"h"]
tmp3D[3,,"j"] <- tmp3D[3,c(2,4,3,1),"h"]
## now
rowSums(tmp3D[,,1]) == rowSums(tmp3D[,,2])
rowSums(tmp3D[,,1]) == rowSums(tmp3D[,,3])
likertWeighted(tmp3D, h.resizePanels=rowSums(tmp3D[,,1]),
main="simplest 3D example, array method")
likertWeighted(tmp3D, h.resizePanels=rowSums(tmp3D[,,1]),
between=list(x=1, y=c(0, 1)),
main="simplest 3D example, array method, with subgroups")
## Same example with explicit use of the formula method
## (array method does this for you).
tmp3Ddf <- toCQxR(tmp3D)
dimnames(tmp3Ddf)
tmp3Ddf
likertWeighted(~ . | group + row, tmp3Ddf, h.resizePanels=rowSums(tmp3D[,,1]),
main="simplest 3D example, formula method")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.