pyramidLikert | R Documentation |
Prints a likert plot in the traditional format for a population pyramid, with the Left and Right sides in separate panels, with the x-tick marks on the left side made positive, and with the y-axis in the Middle.
## S3 method for class 'pyramidLikert'
print(x, ...,
panel.width=.48,
px=list(
L=c(0, panel.width),
R=c(1-panel.width, 1),
M=c(panel.width, 1-panel.width)),
keepLegend=(length(x$legend$bottom$args$text) > 2),
xlab.top=list(
L=list(x$legend$bottom$args$text[1]),
R=list(x$legend$bottom$args$text[2]),
M=list(x$ylab, just=1)))
as.pyramidLikert(x, ...,
panel.width=.48,
px=list(
L=c(0, panel.width),
R=c(1-panel.width, 1),
M=c(panel.width, 1-panel.width)),
keepLegend=(length(x$legend$bottom$args$text) > 2),
xlab.top=list(
L=list(x$legend$bottom$args$text[1]),
R=list(x$legend$bottom$args$text[2]),
M=list(x$ylab, just=1)))
x |
a single-panel |
... |
Other arguments are ignored. |
panel.width |
Numeric scalar between 0 and 0.5. Common width of left and right panels. The default
value .48 value works well for the |
px |
|
keepLegend |
If |
xlab.top |
A vector of three labels. The default is designed for a population triangle with two levels (usually, Male on one side and Female on the other). The Left and Right labels are taken from the first two labels in the legend. The Middle value is the variable name for the y-axis. |
This is a print method for population triangles. It is designed for a
likert plot with one left-side level and one right-side level.
It works for any single-panel "trellis"
object, in the sense
that it produces a plot.
The input argument x
.
Richard M. Heiberger <rmh@temple.edu>
likert
data(USAge.table) ## from latticeExtra
USA79 <- USAge.table[75:1, 2:1, "1979"]/1000000
PL <- plot(as.likert(USA79),
main="Population of United States 1979 (ages 0-74)",
xlab="Count in Millions",
ylab="Age",
scales=list(
y=list(
limits=c(0,77),
at=seq(1,76,5),
labels=seq(0,75,5),
tck=.5))
)
PL
as.pyramidLikert(PL)
likert(USAge.table[75:1, 2:1, c("1939","1959","1979")]/1000000,
main="Population of United States 1939,1959,1979 (ages 0-74)",
sub="Look for the Baby Boom",
xlab="Count in Millions",
ylab="Age",
scales=list(
y=list(
limits=c(0,77),
at=seq(1,76,5),
labels=seq(0,75,5),
tck=.5)),
strip.left=FALSE, strip=TRUE,
layout=c(3,1), between=list(x=.5))
## Not run:
## run the shiny app
if (interactive()) shiny::runApp(system.file("shiny/PopulationPyramid", package="HH"))
## End(Not run)
## For additional examples, see demo(PoorChildren, package="HH")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.