Boxplot

Share:

Description

Draw a box, a violin, a box-percentile and more plots for subgroups

Usage

1
2
3
4
5
6
box.plot.ade(x, group=NULL, group2=NULL, data=NULL, vnames=NULL,
             main=NULL, xlab=NULL, ylab=NULL, ylim=NULL, yticks=NULL,
             col=NULL, tcol=NULL, bgcol=NULL, lcol=NULL, pdigs=4, alpha=NULL,
             cex=1, cex.axis=1, lwd=2, h=NULL, lty=2, test=FALSE,
             varwidth=TRUE, means=FALSE, count=TRUE, zylinder=FALSE,
             twoside=TRUE, paired=FALSE, outlier=TRUE, wall=0, type='box')

Arguments

x
  • a numeric vector of values

  • a character string with the name of the variable in the data.frame

  • a formula x~group or x~group+group2

group
  • a factor to group the plots

  • a character string with the name of the group variable in the data.frame

group2
  • a second factor to group the plots

  • a character string with the name of the group2 variable in the data.frame

data

a data.frame

vnames

a vector of character strings with the names of groups in the legend, it can be a list of two vectors if group2 is given

main

an overall title for the plot

xlab

a title for the x axis

ylab

a title for the y axis

ylim

the y limits (y1, y2) of the plot

yticks

the number of ticks on the y axis or a vector of exact ticks

col

color of objects (Boxes)

tcol

color of the text in whole plot

bgcol

the background color for plot dekoration

lcol

color for the lines in plot, a vector of colors is possible

pdigs

a number indicate how to round p-values.: see ?format.pval.ade

alpha

a parameter in [0, 1] for semi-transparency of objects (Boxes)

cex

a numeric character expansion factor for the points

cex.axis

a numeric character expansion factor for axis

lwd

the line width

h

the y-value(s) for horizontal line(s).

lty

the line type

test
  • logical asking whether to test for the difference or trend between groups

  • a string to print before p-value. (leads to test=T)

varwidth

logical asking whether the boxwidth indicate the N

means

logical asking whether to draw points for the means

count
  • logical asking whether to shown N

  • a string to replace N with it, if you use "?" in you string in will be replaced with N.

  • a vector of strings to replace N with it, if you use "?" in you strings in will be replaced with N.

zylinder

logical asking whether to draw boxes in a zylinder style

twoside

logical asking whether to perform a wto sided test, or a test with direction

paired

logical indicating whether you want a paired test.

outlier

logical asking whether to draw points for outlier

wall

a number between 0 and 6 for selection the dekoration style of the plot.

type

one of following:

  • "boxplot" for a normal boxplot

  • "violin" for a violinplot

  • "sd" for mean and one sd interval

  • "2sd" for mean and one, two sd intervals

  • "percentile" for a box-percentile plot

  • "iqr" for a IQR plot

Details

it test for difference with T-test or U-test depends on the skewness <= 1 or >1. For a trend it perform a Jonckheere-Terpstra trend test.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x<-rnorm(1000)
g<-round(runif(1000))
g2<-round(runif(1000))
box.plot.ade(x, g, g2, vnames=list(c("subgroup 1","subgroup 2"),
c("group 1", "group 2")), wall=0, count='N: ?', means=TRUE)
box.plot.ade(x, g, g2, vnames=list(c("subgroup 1","subgroup 2"),
c("group 1", "group 2")), wall=1, type="violin")
box.plot.ade(x, g, g2, vnames=list(c("subgroup 1","subgroup 2"),
c("group 1", "group 2")), wall=2, type="percentile")
box.plot.ade(x, g, g2, vnames=list(c("subgroup 1","subgroup 2"),
c("group 1", "group 2")), wall=3, type="sd")