toxplot: toxplot

View source: R/plot2.R

toxplotR Documentation

toxplot

Description

Draw a toxicity summary plot.

Usage

toxplot(
  ftable,
  total,
  digits = 0L,
  headers = NULL,
  xlim = NULL,
  order = c("none", "decreasing", "increasing"),
  label.bars = c("n", "percent", "none"),
  col.bars = NULL,
  digits.bars = digits,
  widths = c(1, 1, 2),
  space = 1,
  xaxis.at = NULL,
  col.bg = "grey",
  alpha.bg = c(0.25, 0.5),
  legend = TRUE,
  args.legend = list(),
  ...
)

Arguments

ftable

a two- or three-dimensional ftable

total

total number of patients (for percentages)

digits

number of places past the decimal to keep for percentages

headers

a vector of labels for text column headers

xlim

the x-axis limits for the bar plot

order

optional ordering for the rows, one of "none" (default), "decreasing", or "increasing"; note that 3-d tables should not be re-ordered

label.bars

optional text on each bar, one of "n" (default), "percent", or "none"

col.bars

a vector of colors for each column of ftable

digits.bars

number of places past the decimal to keep for label.bars text

widths

the relative width of each column

space

additional space between final text column and bar plot

xaxis.at

x-axis tick positions

col.bg, alpha.bg

background color for text columns with alternating alpha.bg transparency

legend

logical; if TRUE, a legend for the col.bars is shown

args.legend

an optional named list of arguments passed to legend

...

additional graphical parameters passed to par

Examples

## example from rawr::tabler_by
set.seed(1)

f <- function(x, ...) sample(x, 100, replace = TRUE, ...)
tox <- data.frame(
  id = rep(1:10, 10), phase = 1:2,
  code = f(rawr::ctcae_v4$tox_code[1:100]),
  grade = f(1:3, prob = c(.6, .3, .1)),
  stringsAsFactors = FALSE
)
tox <- cbind(tox, rawr::match_ctc(tox$code)[, c('tox_cat', 'tox_desc')])

t1 <- ftable(
  Category = tox$tox_cat,
  Description = tox$tox_desc,
  Grade = tox$grade
)
t2 <- ftable(
  Description = tox$tox_desc,
  Grade = tox$grade
)
n <- 25


## basic usage
toxplot(t1, n) ## three column
toxplot(t2, n) ## two column


toxplot(
  t2, n, widths = c(1, 3), label.bars = 'percent',
  headers = c('Toxicity description', 'N (%)'),
  order = 'dec', xlim = c(0, 10), xaxis.at = c(0, 5, 10),
  args.legend = list(x = 'bottomright', horiz = FALSE, cex = 2)
)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.