BiAxisErrBar: Compare Patterns of Two Outcomes in One Scatter Plot

Description Usage Arguments Value Author(s) Examples

View source: R/BiAxisErrBar.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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 data that indicates the predictor.

y.left

character. The column name of data that indicates the first outcome variable, the error bar plot of which will be drawn on the left side.

y.right

character. The column name of data that indicates the second outcome variable, the error bar plot of which will be drawn on the right side.

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 delta distance from the first error bar plot.

cvThresh

numeric. A small positive number. If the coefficient of variation (CV) is smaller than cvThresh, then the scaling factor will be set to one.

Ntick

integer. Number of ticks on the two y-axes.

semFlag

logical. Indicating if standard error of the mean (semFlag = TRUE) or standard error (semFlag = FALSE) will be used to construct the error bars.

GroupLevel

A vector of unique values of group indicating the order of group shown in x-axis.

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

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

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