library(HH)
data(ProfChal)
## Putting both percents and counts on the same plot requires
## coordination. The easiest way is to order the original tables of
## counts by the order of the percent plot.
names(ProfChal)[6] <- "Prof Recog" ## reduce length of label
percentPlot <- likert(ProfChal, as.percent="noRightAxis", positive.order=TRUE,
main="Is your job professionally challenging?",
strip.left.par=list(cex=.7))
## percentPlot
pct.order <- percentPlot$y.limits
ProfChal.pct.order <- sapply(seq(along=ProfChal),
function(i, mylist, myorder)
{mylist[[i]][rev(myorder[[i]]),,drop=FALSE]},
ProfChal, pct.order,
simplify=FALSE)
names(ProfChal.pct.order) <- names(ProfChal)
class(ProfChal.pct.order) <- class(ProfChal)
countPlot <- likert(ProfChal.pct.order, rightAxis=TRUE,
scales=list(x=list(at=c(0, 250, 500))),
main="Is your job professionally challenging?")
## countPlot
names(ProfChal)[6] <- "Attitude
toward
Professional
Recognition" ## Restore original label
as.TwoTrellisColumns(percentPlot, countPlot,
px=list(L=c(0,.77), ## left labels and left panel ## Overlap is ok.
M=c(.60,.61), ## main, sub, and legend of left ## Do it visually for
R=c(.71,1))) ## right panel and right labels ## the graphics window width.
as.TwoTrellisColumns5(percentPlot, countPlot) ## bad overlap for this example with 7in x 7in window
as.TwoTrellisColumns5(percentPlot, countPlot, ## acceptable in 7in x 7in
pw=c(.528, .186, .01, .186, .09)) ## These 5 numbers must sum to 1.
as.TwoTrellisColumns5(percentPlot, countPlot, ## better in 7in x 7in
px=list(
LL=c(0.000, 0.528), ## 0.528 makes LL and LP touch without overlap ## left labels and strip.left
LP=c(0.528, 0.714), ## left panel
ML=c(0.580, 0.581), ## shifted left, to center main and key ## main, sub, key from left argument
RP=c(0.724, 0.910), ## gap from 0.714 to 0.724 puts space between columns ## right panel
RL=c(0.920, 1.000))) ## extra space ## right labels
Run the code above in your browser using DataLab