Box {statVisual}R Documentation

Compare Groups Based on Boxplots Across Time

Description

This function is to compare groups using boxplots at each time point. In addition, line segments are used to connect the mean/median of each boxplot of the same group across time to show the differences between the mean trajectories.

Usage

Box(
    data, 
    x = NULL, 
    y, 
    group = NULL, 
    fill = NULL, 
    theme_classic = TRUE, 
    fill.alpha = 0.7, 
    box.width = 0.5, 
    dodge.width = 0.8, 
    jitter = TRUE, 
    jitter.alpha = 0.7, 
    jitter.width = 0.2, 
    point.size = 1, 
    xlab = x, 
    ylab = y, 
    group.lab = group, 
    fill.lab = group, 
    title = "Boxplot", 
    line = "mean", 
    line.color = "black", 
    xLevel = NULL,
    addThemeFlag = TRUE,
    ...)

Arguments

data

A data frame. Rows are subjects; Columns are variables describing the subjects.

x

character. The column name of data that indicates the first grouping variable (e.g. observation time)

y

character. The column name of data that indicates the variable on y axis

group

character. The column name of data that indicates the subject groups (e.g., treatment group). The boxplots will be drawn for each of the subject group within each category of x.

fill

boxplot inside color indicated by the categories of group

theme_classic

logical. Use classic background without grids (default: TRUE).

fill.alpha

boxplot transparency

box.width

boxplot width

dodge.width

dodge width for boxplot and jitter (prevent overlapping)

jitter

logical. plot jitter or not, default TRUE

jitter.alpha

jitter transparency

jitter.width

jitter width in boxplot

point.size

size of a jitter point

xlab

character. x axis label

ylab

character. y axis label

group.lab

label of group variable

fill.lab

label of fill variable

title

character. title of plot

line

line connect boxes, default plot mean, can be set as 'median', or NULL (no line)

line.color

connection line color, only available when group = NULL

xLevel

character. A character vector indicating the order of the elements of x to be shown on x-axis if is.null(x)==FALSE.

addThemeFlag

logical. Indicates if light blue background and white grid should be added to the figure.

...

other input parameters for facet & theme

Value

A list with the following 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(dplyr)

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 = 'Box', 
           data = longDat, 
           x = 'time', 
           y = 'y', 
           group = 'grp',
	   title = "Boxplots across time") 

Box( 
    data = longDat, 
    x = 'time', 
    y = 'y', 
    group = 'grp',
    title = "Boxplots across time") 



[Package statVisual version 1.2.1 Index]