tox_worst | R Documentation |
Returns a subset of input data with worst toxicity grade per toxicity code per patient, ie, sorts and removes duplicates.
tox_worst(
data,
id = "id",
desc = "desc",
grade = "grade",
code = NULL,
version = 4L
)
data |
toxicity data frame |
id |
column name with identifier |
desc |
column name with toxicity descriptions (or codes) |
grade |
column name with toxiticity grades; should be a factor with the desired order to be properly sorted, i.e., least to most severe |
code , version |
if note that |
A filtered data frame with attributes:
attr(., "data") |
the input data frame sorted by |
attr(., "duplicates" |
the indices of rows removed from
|
match_ctc
, tabler_by
; tabler_by2
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:10]),
grade = factor(f(1:3, prob = c(.3, .4, .3))))
## get worst tox by CTCAE code
## this will convert the code to description strings
tox1 <- tox_worst(tox, id = 'id', grade = 'grade', code = 'code')
## or by formatted descriptions and grade
tox$desc <- factor(match_ctc(tox$code)$tox_desc)
tox2 <- tox_worst(tox, id = 'id', grade = 'grade', desc = 'desc')
## both methods are equivalent
stopifnot(identical(tox1, tox2))
## these rows have been removed from attr(tox1, 'data')
attr(tox1, 'duplicates')
stopifnot(
all.equal(tox1, attr(tox1, 'data')[-attr(tox1, 'duplicates'), ],
check.attributes = FALSE)
)
## use tabler_by/tabler_by2 to summarize
tabler_by(tox1, 'desc', 'grade', n = 10, pct.sign = FALSE)
tabler_by2(tox1, 'desc', 'grade', stratvar = 'phase')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.