compareBars | R Documentation |
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.
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)
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 |
... |
Other arguments to |
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.cex |
Character magnification for legend. |
col |
The normal graphics |
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
|
sub |
Character scalar giving sub title (see
|
xlab |
Character scalar giving x-axis label (see
|
ylab |
Character scalar giving x-axis label (see
|
rotlab |
If |
error.bars |
The number of standard errors for error bars. |
err.col |
The color for error bars. |
scale |
Scales data as probabilities ( |
Invisibly returns the x-co-ordinates of the bars.
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.
Russell Almond
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.
stackedBars
, colorspread
,
buildFactorTab
, barplot
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.