propBarchart {flexclust} | R Documentation |
Barcharts and Boxplots for Columns of a Data Matrix Split by Groups
Description
Split a binary or numeric matrix by a grouping variable, run a series of tests on all variables, adjust for multiple testing and graphically represent results.
Usage
propBarchart(x, g, alpha=0.05, correct="holm", test="prop.test",
sort=FALSE, strip.prefix="", strip.labels=NULL,
which=NULL, byvar=FALSE, ...)
## S4 method for signature 'propBarchart'
summary(object, ...)
groupBWplot(x, g, alpha=0.05, correct="holm", xlab="", col=NULL,
shade=!is.null(shadefun), shadefun=NULL,
strip.prefix="", strip.labels=NULL, which=NULL, byvar=FALSE,
...)
Arguments
x |
A binary data matrix. |
g |
A factor specifying the groups. |
alpha |
Significance level for test of differences in proportions. |
correct |
Correction method for multiple testing, passed to
|
test |
Test to use for detecting significant differences in proportions. |
sort |
Logical, sort variables by total sample mean? |
strip.prefix |
Character string prepended to strips of the
|
strip.labels |
Character vector of labels to use for strips of
|
which |
Index numbers or names of variables to plot. |
byvar |
If |
... |
|
object |
Return value of |
xlab |
A title for the x-axis: see |
col |
Vector of colors for the panels. |
shade |
If |
shadefun |
A function or name of a function to compute which
boxes are shaded, e.g. |
Details
Function propBarchart
splits a binary data matrix into
subgroups, computes the percentage of ones in each column and compares
the proportions in the groups using prop.test
. The
p-values for all variables are adjusted for multiple testing and a
barchart of group percentages is drawn highlighting variables with
significant differences in proportion. The summary
method can
be used to create a corresponding table for publications.
Function groupBWplot
takes a general numeric matrix, also
splits into subgroups and uses boxes instead of bars. By default
kruskal.test
is used to compute significant differences
in location, in addition the heuristics from
bwplot,kcca-method
can be used. Boxes of the complete sample
are used as reference in the background.
Author(s)
Friedrich Leisch
See Also
barplot-methods
,
bwplot,kcca-method
Examples
## create a binary matrix from the iris data plus a random noise column
x <- apply(iris[,-5], 2, function(z) z>median(z))
x <- cbind(x, Noise=sample(0:1, 150, replace=TRUE))
## There are significant differences in all 4 original variables, Noise
## has most likely no significant difference (of course the difference
## will be significant in alpha percent of all random samples).
p <- propBarchart(x, iris$Species)
p
summary(p)
propBarchart(x, iris$Species, byvar=TRUE)
x <- iris[,-5]
x <- cbind(x, Noise=rnorm(150, mean=3))
groupBWplot(x, iris$Species)
groupBWplot(x, iris$Species, shade=TRUE)
groupBWplot(x, iris$Species, shadefun="medianInside")
groupBWplot(x, iris$Species, shade=TRUE, byvar=TRUE)