compareBars: Produces comparison stacked bar charts for two sets of groups

compareBarsR Documentation

Produces comparison stacked bar charts for two sets of groups

Description

This produces set of stacked bar charts grouped for comparison between two groups. For example, if suppose that there is a set of probabilities over a collection of proficiency variables measures both before and after obtaining a certain piece of evidence. The compareBars function would produce stacked bar charts which compare the prior and posterior probabilities for each variable.

Usage

compareBars(data1, data2, profindex,
            groupNames = c(deparse(data1), deparse(data2)), ...,
            ylim = c(min(offsets) - 0.25, max(1 + offsets)),
            cex.names = par("cex.axis"), digits = 2, legend.loc = c(0,1),
            legend.cex = par("cex"), col = par("col"), col1 = NULL,
            col2 = NULL, main = NULL, sub = NULL, xlab = NULL,
            ylab = NULL, rotlab = FALSE)

compareBars2(data1, data2, profindex,
             groupNames=c("Prior","Post"), error.bars=2, scale=100,
             err.col="gray20", ..., ylim = NULL) 

Arguments

data1

Data set with first (prior) values

data2

Data set with second (posterior) values

profindex

Index of one of the proficiency levels which will be used as the baseline for the stacked bar charts.

groupNames

Names of the groups represented by data1 and data2 respectively.

...

Other arguments to barplot.

ylim

Default limits for Y axis.

cex.names

Character magnification for names.

digits

Number of digits for overlaid numeric variables.

legend.loc

Location for legend, see legend.

legend.cex

Character magnification for legend.

col

The normal graphics col parameter (see par, passed through to other graphics operators using .... Is also the default for col1 and col2 if those values are not supplied.

col1

Color scale for the first data set. This should be a vector of colors equal to the number of groups.

col2

Color scale for the second data set. This should be a vector of colors equal to the number of groups.

main

Character scalar giving main title (see title).

sub

Character scalar giving sub title (see title).

xlab

Character scalar giving x-axis label (see title).

ylab

Character scalar giving x-axis label (see title).

rotlab

If TRUE labels are rotated 90 degrees.

error.bars

The number of standard errors for error bars.

err.col

The color for error bars.

scale

Scales data as probabilities (scale=1) or percentages (scale=100).

Value

Invisibly returns the x-co-ordinates of the bars.

Note

The function compareBars2 is a somewhat experimental extension to compareBars which adds error bars to the posterior. The result is not entirely satisfactory, and this function may change with future releases.

Author(s)

Russell Almond

References

Almond, R. G., Shute, V. J., Underwood, J. S., and Zapata-Rivera, J.-D (2009). Bayesian Networks: A Teacher's View. International Journal of Approximate Reasoning. 50, 450-460.

See Also

stackedBars, colorspread, buildFactorTab, barplot

Examples

margins.prior <- data.frame (
 Trouble=c(Novice=.19,Semester1=.24,Semester2=.28,Semseter3=.20,Semester4=.09),
 NDK=c(Novice=.01,Semester1=.09,Semester2=.35,Semseter3=.41,Semester4=.14),
 Model=c(Novice=.19,Semester1=.28,Semester2=.31,Semseter3=.18,Semester4=.04)
)

margins.post <- data.frame(
 Trouble=c(Novice=.03,Semester1=.15,Semester2=.39,Semseter3=.32,Semester4=.11),
 NDK=c(Novice=.00,Semester1=.03,Semester2=.28,Semseter3=.52,Semester4=.17),
 Model=c(Novice=.10,Semester1=.25,Semester2=.37,Semseter3=.23,Semester4=.05))

foo <-
compareBars(margins.prior,margins.post,3,c("Prior","Post"),
            main="Margins before/after Medium Trouble Shooting Task",
            sub="Observables:  cfgCor=Medium, logCor=High, logEff=Medium",
            legend.loc = "topright",
            cex.names=.75, col1=hsv(h=.1,s=.2*1:5-.1,alpha=1),
            col2=hsv(h=.6,s=.2*1:5-.1,alpha=1))

compareBars2(margins.prior,25*margins.post,3,c("Prior","Post"),
            main="Margins before/after Medium Trouble Shooting Task",
            sub="Observables:  cfgCor=Medium, logCor=High, logEff=Medium",
            legend.loc = "topright",
            cex.names=.75, col1=hsv(h=.1,s=.2*1:5-.1,alpha=1),
            col2=hsv(h=.6,s=.2*1:5-.1,alpha=1))





ralmond/CPTtools documentation built on Dec. 27, 2024, 7:15 a.m.