This function is to compare groups using barplots at each time point.
In addition, line segments are used to connect the mean/median of each barplot
of the same group across time to show the differences between
the mean trajectories.
Also, for each barplot
the barplot of mean
barPlot(
data,
x = NULL,
y,
group = NULL,
semFlag = TRUE,
xFlag = FALSE,
bar.width = 0.5,
dodge.width = 0.8,
jitter = FALSE,
jitter.alpha = 0.7,
jitter.width = 0.1,
line = NULL,
line.color = "black",
xlab = x,
ylab = line,
theme_classic = TRUE,
group.lab = group,
title = "bar plots",
xLevel = NULL,
addThemeFlag = TRUE,
...)
A data frame. Rows are subjects; Columns are variables describing the subjects.
character. The column name of data
that indicates the first grouping variable
character. The column name of data
that indicates the variable on y axis
character. The column name of data
that indicates the subject groups. The barplots will be drawn for each of the subject group within each category of x
.
logical. Indicate if sem or se should be used to draw error bar
logical. Indicate if x
should be treated as continuous (xFlag=TRUE
)
numeric. error bar width
numeric. dodge width for error bar and jitter (prevent overlapping)
logical, plot jitter or not, default TRUE
numeric. jitter transparency
numeric. jitter width in error bar
character. line connect error bar, default uses mean, can be set as 'median', NULL (no line)
character. connection line color, only available when group = NULL
character. x axis label
character. y axis label
logical. Use classic background without grids (default: TRUE).
character. label of group variable
character. title of plot
character. A character vector indicating the order of the elements of x
to be shown on x-axis if is.null(x)==FALSE
.
logical. Indicates if light blue background and white grid should be added to the figure.
other input parameters for facet & theme
A list of the following 9 elements: “data”, “layers”, “scales”, “mapping”, “theme”, “coordinates”, “facet”, “plot_env”, “labels”.
# NOT RUN {
data(longDat)
print(dim(longDat))
print(longDat[1:3,])
print(table(longDat$time, useNA = "ifany"))
print(table(longDat$grp, useNA = "ifany"))
print(table(longDat$sid, useNA = "ifany"))
print(table(longDat$time, longDat$grp))
statVisual(type = 'barPlot',
data = longDat,
x = 'time',
y = 'y',
group = 'grp',
title = "Bar plots across time")
barPlot(
data = longDat,
x = 'time',
y = 'y',
group = 'grp',
title = "Bar plots across time")
# }
Run the code above in your browser using DataLab