stackedBarPlot: Draw Stacked Bar Plots

Description Usage Arguments Value Author(s) Examples

View source: R/stackedBarPlot.R

Description

Draw stacked bar plots.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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 catVar should be shown in x-axis.

groupLevel

character. A vector indicating the order of the unique elements of group should be shown in figure and in legend.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)

statVisual documentation built on Feb. 21, 2020, 1:08 a.m.