Learn R Programming

reReg (version 1.3.0)

plotEvents: Produce Event Plots

Description

Plot the event plot for an Recur object. The usage of the function is similar to that of plot.Recur() but with more flexible options.

Usage

plotEvents(
  formula,
  data,
  result = c("increasing", "decreasing", "asis"),
  control = list(),
  ...
)

Arguments

formula

a formula object, with the response on the left of a "~" operator, and the predictors on the right. The response must be a recurrent event survival object as returned by function Recur().

data

an optional data frame in which to interpret the variables occurring in the "formula".

result

an optional character string specifying whether the event plot is sorted by the subjects' terminal time. The available options are

increasing

sort the terminal time from in ascending order (default). This places longer terminal times on top.

decreasing

sort the terminal time from in descending order (default). This places shorter terminal times on top.

asis

present the as is, without sorting.

control

a list of control parameters.

...

graphical parameters to be passed to methods. These include xlab, ylab, main, and more. See Details.

Value

A ggplot object.

Details

The argument control consists of options with argument defaults to a list with the following values:

xlab

customizable x-label, default value is "Time".

ylab

customizable y-label, default value is "Subject".

main

customizable title, default value is "Recurrent event plot".

terminal.name

customizable label for terminal event, default value is "Terminal event".

recurrent.name

customizable legend title for recurrent event, default value is "Recurrent events".

recurrent.types

customizable label for recurrent event type, default value is NULL.

alpha

between 0 and 1, controls the transparency of points.

legend

a character string specifying the position of the legend (if any). The available options are "right", "left", "top", "bottom", and "none". The default value is "right".

See Also

Recur, plot.Recur

Examples

Run this code
# NOT RUN {
data(simDat)
plotEvents(Recur(Time, id, event, status) ~ 1, data = simDat,
           xlab = "Time in days", ylab = "Subjects arranged by terminal time")

## Separate plots by x1
plotEvents(Recur(Time, id, event, status) ~ x1, data = simDat)

## For multiple recurrent events
simDat$x3 <- ifelse(simDat$x2 < 0, "x2 < 0", "x2 > 0")
simDat$event <- simDat$event * sample(1:3, nrow(simDat), TRUE)
plotEvents(Recur(Time, id, event, status) ~ x1 + x3, data = simDat)
# }

Run the code above in your browser using DataLab