BiAxisErrBar {statVisual} | R Documentation |
Compare Patterns of Two Outcomes in One Scatter Plot
Description
Compare patterns of two outcomes with different scales across the range of the common predictor using error bar plots. Each bar plot displays mean +/-
standard error.
Usage
BiAxisErrBar(dat,
group,
y.left,
y.right,
title = "Bi-Axis Error Bar Plot",
xlab = group,
ylab.left = y.left,
ylab.right = y.right,
legendLabel = "y axis variables",
delta = NULL,
cvThresh = 0.01,
Ntick = 5,
semFlag = TRUE, #semFlag = FALSE if SE is required
GroupLevel = NULL,
addThemeFlag = FALSE
)
Arguments
dat |
A data frame. Rows are subjects; Columns are variables describing the subjects. |
group |
character. A categorical variable in |
y.left |
character. The column name of |
y.right |
character. The column name of |
title |
character. title of the plot. |
xlab |
character. Label for the x-axis. |
ylab.left |
character. Label for the left-side y-axis. |
ylab.right |
character. Label for the right-side y-axis. |
legendLabel |
character. Legend label. |
delta |
numeric. A small number so that the second error bar plot will shift |
cvThresh |
numeric. A small positive number. If the coefficient of variation (CV)
is smaller than |
Ntick |
integer. Number of ticks on the two y-axes. |
semFlag |
logical. Indicating if standard error of the mean ( |
GroupLevel |
A vector of unique values of |
addThemeFlag |
logical. Indicates if light blue background and white grid should be added to the figure. |
Value
A list with 9 elements.
data
, layers
, scales
, mapping
,
theme
, coordinates
,
facet
, plot_env
, and 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
library(tidyverse)
library(ggplot2)
print(head(mtcars))
print(table(mtcars$gear, useNA="ifany"))
statVisual(type = "BiAxisErrBar",
dat= mtcars,
group = "gear",
y.left = "mpg",
y.right = "wt")
BiAxisErrBar(
dat = mtcars,
group = "gear",
y.left = "mpg",
y.right = "wt")