likertMosaic | R Documentation |
Constructs and plots diverging stacked barcharts for Likert, semantic
differential, rating scale data, and population pyramids,
.based on mosaic
as the plotting style.
likertMosaic(x, ...)
## S3 method for class 'formula'
likertMosaic(x, data, ReferenceZero = NULL, spacing=NULL,
..., between.y = c(1.2, 0.3))
## S3 method for class 'array'
likertMosaic(x, ReferenceZero = NULL, col = NULL, main = NULL,
...,
as.percent = FALSE, variable.width = NULL, positive.order = FALSE,
Conditions = NULL,
x.legend = list(text = list(dimnames(x)[[ndim]]),
columns = x.dim[ndim],
space = "bottom",
size = 2,
cex = 0.8,
between = 0.6,
rect= list(col = col, border = "white")),
legend.y = 0.05,
spacing = spacing_highlighting,
split_vertical = c(TRUE, FALSE),
margins = c(3, 2, 4, 22),
keep_aspect = FALSE,
rot_labels = c(0, 0, 90, 0),
just_labels = c("center", "center", "center", "right"),
labels = c(TRUE, TRUE, FALSE, TRUE),
varnames = FALSE,
zero_size = 0,
gp = gpar(fill = col.extended, col = 0),
colorFunction="diverge_hcl",
colorFunctionOption="lighter")
## S3 method for class 'data.frame'
likertMosaic(x, ...)
## Default S3 method:
likertMosaic(x, ...) ## most likely for a vector
## S3 method for class 'list'
likertMosaic(x, ...)
## S3 method for class 'matrix'
likertMosaic(x, ...,
split_vertical = c(FALSE, TRUE),
rot_labels = c(90, 0, 0, 0),
just_labels = c("left", "center", "center", "right"),
labels = c(TRUE, FALSE))
x |
For the formula method, a model formula. Otherwise,
any numeric object stored as a vector, matrix, array,
data.frame, table, ftable,
structable (as defined in the |
data |
For the formula method, a |
ReferenceZero |
Numeric scalar or |
positive.order |
If |
as.percent |
When |
variable.width |
When |
col |
Colors for the bars. With the default value |
colorFunction , colorFunctionOption |
See |
main |
|
... |
Additional arguments, passed to the next method and possibly all the way
to |
Conditions |
Factor used to divide the rows of the plot into sets of rows
corresponding to levels of Condition. In the formula method, the
conditions are the factors appearing after the |
between.y |
vertical spacing between bars. |
x.legend |
Description of legend using the terminology and conventions of the
|
legend.y |
Adjust vertical location of legend. |
spacing , split_vertical , margins , keep_aspect , rot_labels , just_labels , labels |
Please see |
varnames , zero_size , gp |
Please see |
The counts (or percentages) of respondents on each row who agree with
the statement are shown to the right of the zero line; the counts (or
percentages) who disagree are shown to the left. The counts (or
percentages) for respondents who neither agree nor disagree are split
down the middle and are shown in a neutral color. The neutral category
is omitted when the scale has an even number of choices.
It is difficult to compare
lengths without a common baseline. In this situation, we are primarily
interested in the total count (or percent) to the right or left of the
zero line; the breakdown into strongly or not is of lesser interest so
that the primary comparisons do have a common baseline of zero. The
rows within each panel are displayed in their original order by
default. If the argument positive.order=TRUE
is specified, the rows
are ordered by the counts (or percentages) who agree.
Diverging stacked barcharts are also called "two-directional stacked barcharts". Some authors use the term "floating barcharts" for vertical diverging stacked barcharts and the term "sliding barcharts" for horizontal diverging stacked barcharts.
All items in a list of named two-dimensional objects must have the
same number of columns. If the items have different column names, the
column names of the last item in the list will be used in the key. If
the dimnames of the matrices are named, the names will be used in the
plot. It is possible to produce a likert plot with a list of objects
with different numbers of columns, but not with the
plot.likert.list
method. These must be done manually by using
the ResizeEtc
function on each of the individual likert
plots. The difficulty is that the legend is based on the last item in
the list and will have the wrong number of values for some of the
panels.
A single data.frame x
will be plotted as data.matrix(x)
;
therefore factor columns will be converted to integers and character
columns will become NA
and will be plotted as if they had value
0. A data.frame with only numeric columns will work in a named list.
A data.frame with factors or characters won't work in a named list.
ftable and structable arguments x
will be plotted as
as.table(x)
. This changes the display sequence.
Therefore the user will probably want to use aperm
on the
ftable or structable before using plot.likert
.
Please see strucplot
for a description of the
returned object.
The functions described here are currently missing the following features:
no axis ticks, number, nor axis label for the x axis
no zero reference line
no right-axis labels for Row Count Totals
no strip.left labels for grouping by Conditions
In Figure 8 and 9 (HH/demo/likertMosaic-paper.r
),
no control of the thickness of the bars
All bars are horizontal.
No borders on the overall plot nor on the panels in plots with grouping by Conditions
No control of between=list(x=number)
cex
for labeling
border on empty boxes
I am using a lattice legend, not a native strucplot legend
Richard M. Heiberger, with contributions from Naomi B. Robbins <naomi@nbr-graphs.com>.
Maintainer: Richard M. Heiberger <rmh@temple.edu>
Richard M. Heiberger, Naomi B. Robbins (2014)., "Design of Diverging Stacked Bar Charts for Likert Scales and Other Applications", Journal of Statistical Software, 57(5), 1–32, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v057.i05")}.
Richard Heiberger and Naomi Robbins (2011), "Alternative to Charles Blow's Figure in \"Newt's War on Poor Children\"", Forbes OnLine, December 20, 2011. https://www.forbes.com/sites/naomirobbins/2011/12/20/alternative-to-charles-blows-figure-in-newts-war-on-poor-children-2/
Naomi Robbins (2011), "Visualizing Data: Challenges to
Presentation of Quality Graphics—and Solutions", Amstat News,
September 2011, 28–30.
http://magazine.amstat.org/blog/2011/09/01/visualizingdata/
Luo, Amy and Tim Keyes (2005). "Second Set of Results in from the Career Track Member Survey," Amstat News. Arlington, VA: American Statistical Association.
likert
, mosaic
## See file HH/demo/likertMosaic-paper.r for a complete set of examples.
## Not run:
require(vcd)
data(ProfChal)
likertMosaic(Question ~ . | Subtable, ProfChal,
main="Is your job professionally challenging?")
likertMosaic(Question ~ . | Subtable, ProfChal,
main="Is your job professionally challenging?", as.percent=TRUE)
likertMosaic(Question ~ . | Subtable, ProfChal,
main="Is your job professionally challenging?", as.percent=TRUE,
positive.order=TRUE)
likertMosaic(Question ~ . | Subtable, ProfChal,
main="Is your job professionally challenging?", as.percent=TRUE,
variable.width=TRUE)
EmpRows <- ProfChal$Subtable == "Employment sector"
ProfChal2 <- ProfChal[EmpRows, 1:5]
rownames(ProfChal2) <- substr(ProfChal[EmpRows, "Question"], 1, 5)
likertMosaic(ProfChal2)
likertMosaic(ProfChal2, main="Employment")
likertMosaic(ProfChal2, main="Employment", ReferenceZero=0)
likertMosaic(ProfChal2, main="Employment", ReferenceZero=3.5)
likertMosaic(ProfChal2, main="Employment", ReferenceZero=4)
likertMosaic(ProfChal2, main="Employment", ReferenceZero=6)
likertMosaic(ProfChal2, main="Employment", positive.order=TRUE)
likertMosaic(ProfChal2, main="Employment", variable.width=TRUE)
likertMosaic(~ ., data.frame(ProfChal2), main="Employment", positive.order=TRUE)
likertMosaic(~ ., data.frame(ProfChal2), main="Employment", variable.width=TRUE)
likert(~ ., data.frame(ProfChal2), main="Employment", variable.width=TRUE)
data(SFF8121)
likertMosaic(aperm(SFF8121, c(3,1,2)))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.