addTableToMargin: Create Tabular Environment from Matrix and Add it to Margin.

Description Usage Arguments Author(s) See Also Examples

Description

This is a generalization of function addXlabTable, intended to be a helper function adding tables to plots instead of usual axis annotations. These tables could represent specific structures, e.g. formulas in boxplots. This function takes a matrix and constructs a tabular environment from this. For all options of argument 'margin' the table will always be ordered from inside to outside, e.g. in boxplots factor levels of the nested factor will appear near to the plot and the outer factor will appear more distant (see examples).

Usage

1
2
3
addTableToMargin(mat, margin = c("bottom", "left", "top", "right"),
  merge = TRUE, propMargin = 0.025, Label = list(), Text = list(),
  reorder = FALSE)

Arguments

mat

(matrix) representing the table which will be added to margin; rows represent factors, columns represent factor-levels, rownames will be re-used as rownames of the table in the plot

margin

(character) string specifying the margin to which the table should be added, partial matching is supported

merge

(logial) TRUE = neighboring cells of 'mat' with the same content will be merged to a wider cell. If provided as vector of logicals, each elements will be applied to rows of 'mat' separately, allowing to merge some variables and leaving others untouched.

propMargin

(numeric) value representing the height (bottom, top) or width (left, right) of the margin as proportion of the total height of the figure region. Note, that this will determine the height of the table in the bottom margin also depending on the amount of space available there.

Label

(list) specifying all parameters applicable in function 'text', x- and y-values will be set automatically for factor-labels (rows of the table)

Text

(list) specifying all parameters applicable in function 'text', x- and y-values will be set automatically for character strings appearing in the cells of the table

reorder

(logical) TRUE = 'mat' will be reorder to match the way horizontal boxplots are drawn, i.e. the column order will be inverted, FALSE = 'mat' will be used in the given order

Author(s)

Andre Schuetzenmeister andre.schuetzenmeister@roche.com

See Also

addXlabTable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# these examples should work when run by the user
## Not run: 
old.par <- par(mar=c(8,4,4,2), yaxs="r")
bp  <- boxplot(mpg~cyl:gear, mtcars)
bxp(bp, axes=FALSE)
box()
axis(2)
mat <- getMatrix(mpg~cyl:gear, bp$names)

# default is table below the plot (margin="bottom") 
addTableToMargin(mat)
par(old.par)

# place table in left margin
old.par <- par(mar=c(4,8,4,3), xaxs="r")
bxp(boxplot(mpg~cyl:gear, mtcars, horizontal=TRUE ), axes=FALSE, 
	   horizontal=TRUE)
box()
axis(1)
addTableToMargin(mat, margin="left", reorder=TRUE)
par(old.par)

# place table in upper margin
old.par <- par(mar=c(4,3,8,2), yaxs="r")
bxp(boxplot(mpg~cyl:gear, mtcars), axes=FALSE)
box()
axis(2)
addTableToMargin(mat, margin="top") 
par(old.par)

# place table in right margin
old.par <- par(mar=c(4,3,3,8))
bxp(boxplot(mpg~cyl:gear, mtcars, horizontal=TRUE), axes=FALSE, 
	   horizontal=TRUE)
box()
axis(1)
addTableToMargin(mat, margin="right", reorder=TRUE) 
par(old.par)

# changing appearance for labels and cell-content
# Note: table is added as is, without adapting to the way the boxplot is drawn
old.par <- par(mar=c(4,3,3,8))
bxp(boxplot(mpg~cyl:gear, mtcars, horizontal=TRUE), axes=FALSE, horizontal=TRUE)
box()
axis(1)
addTableToMargin(mat, margin="right", Label=list(font=2, col="red"), 
				Text=list(font=3, col="blue")) 
par(old.par)

## End(Not run)

lengning/gClinBiomarker documentation built on May 9, 2019, 2:55 p.m.