Construct treatment timelines (long format)
Source:R/OncReg.txlines.timeline.R
OR.txlines.timeline.RdFor each id, takes treatment lines stored in wide format (one column per
line of treatment for each of treatment regimens, start dates, stop dates,
stop reasons, and event dates) and constructs a time-ordered timeline in long
format. Each output row corresponds to a unique date at which any treatment
starts or stops, or an event (for example, disease progression) occurs. At
each unique date, active treatment regimens and stop reasons are merged.
Usage
OR.txlines.timeline(
id,
regimens,
startdates,
stopdates,
stopreasons = NULL,
eventdates = NULL,
echo = FALSE
)Arguments
- id
Vector of identifiers.
- regimens
Comma-delimited string matrix or data frame of treatment regimens (one row per
id, one column per line of treatment).- startdates
Numeric matrix or data frame of start dates (one row per
id, one column per line of treatment).- stopdates
Numeric matrix or data frame of stop dates (one row per
id, one column per line of treatment).- stopreasons
Optional comma-delimited string matrix or data frame of stop reasons (one row per
id, one column per line of treatment).- eventdates
Optional numeric matrix or data frame of event dates (one row per
id, one column per line of treatment).- echo
Logical. If
TRUE, prints additional information to console. Default =FALSE.
Value
A data frame in long format with columns:
- id
Identifier.
- date
Date when a treatment starts or stops, or an event occurs.
- regimen
Active regimens at the date.
- stopreasons
Stop reasons occurring at the date.
- event
Logical indicating whether an event occurs at the date.
See also
Other txlines:
OR.txlines.restart(),
OR.txlines.truncate(),
OR.txlines.wide()