stackedBarPlot {statVisual} | R Documentation |
Draw Stacked Bar Plots
Description
Draw stacked bar plots.
Usage
stackedBarPlot(dat,
catVar,
group,
xlab = catVar,
ylab = "Count",
group.lab = group,
title = "Stacked barplots of counts",
catVarLevel = NULL,
groupLevel = NULL,
addThemeFlag = TRUE)
Arguments
dat |
A data frame object. Rows are subjects and columns are variables. |
catVar |
character. The name of the cateogrical variable to be shown in x-axis. |
group |
character. The name of variable indicating groups of subjects. |
xlab |
character. Label for x-axis. |
ylab |
character. Label for y-axis. |
group.lab |
character. Label for group in legend. |
title |
character. Figure title. |
catVarLevel |
character. A vector indicating the order of the unique elements of |
groupLevel |
character. A vector indicating the order of the unique elements of |
addThemeFlag |
logical. Indicates if light blue background and white grid should be added to the figure. |
Value
A list of the following 9 elements: “data”, “layers”, “scales”, “mapping”, “theme”, “coordinates”, “facet”, “plot_env”, “labels”.
Author(s)
Wenfei Zhang <Wenfei.Zhang@sanofi.com>, Weiliang Qiu <Weiliang.Qiu@sanofi.com>, Xuan Lin <Xuan.Lin@sanofi.com>, Donghui Zhang <Donghui.Zhang@sanofi.com>
Examples
data(genoSim)
pDat = pData(genoSim)
geno = exprs(genoSim)
pDat$snp1 = geno[1,]
print(table(pDat$snp1, pDat$grp, useNA="ifany"))
stackedBarPlot(dat = pDat,
catVar = "snp1",
group = "grp",
xlab = "snp1",
ylab = "Count",
group.lab = "grp",
title = "Stacked barplots of counts",
catVarLevel = NULL)