plot.iwillsurvive: Plot an iwillsurvive x.

View source: R/plot_iwillsurvive.R

plot.iwillsurviveR Documentation

Plot an iwillsurvive x.

Description

Plot an iwillsurvive x.

Usage

## S3 method for class 'iwillsurvive'
plot(
  x = NULL,
  ggtheme = ggplot2::theme_bw(),
  palette = "Set1",
  simple = FALSE,
  title = NULL,
  subtitle = NULL,
  censor_pch = "|",
  censor_size = 3,
  add_gridlines = TRUE,
  add_confidence = TRUE,
  add_censor_ticks = TRUE,
  add_labels = TRUE,
  add_median = TRUE,
  add_median_delta = TRUE,
  anchor_arrow = FALSE,
  legend_position = "inside",
  legend_anchor_y = 0.5,
  legend_nudge_y = NULL,
  legend_position_x = NULL,
  xlim = NULL,
  x_breaks = NULL,
  label_size = 3,
  label_color = grDevices::gray(0),
  median_flag_nudge_y = 0.1,
  median_flag_thickness = 0.7,
  risk_table = TRUE,
  risk_table_title = NULL,
  risk_size = 3.5,
  risk_label_size = 1.25,
  index_title = NULL,
  event_title = NULL,
  median_flag_size = 4,
  event_nudge_y = 0.15,
  panel_heights = c(3, 1),
  ...
)

Arguments

x

iwillsurvive. An iwillsurvive object created from iwillsurvive()

ggtheme

theme. A ggplot2 theme

palette

character. The name of a paleete. See ?ggplot2::scale_colour_brewer for examples

simple

logical. If TRUE, only plot the Kaplan-Meier estimate

title

character. Plot title

subtitle

character. Plot subtitle

censor_pch

character. The point shape for censor ticks. See ?points.

censor_size

numeric. Size of censor ticks.

add_gridlines

logical. If TRUE, include gridlines

add_confidence

logical. If TRUE, include a confidence interval

add_censor_ticks

logical. If TRUE, show censoring tick marks

add_labels

logical. If TRUE, show verbal labels

add_median

logical. If TRUE, show median survival

add_median_delta

logical.

anchor_arrow

logical. If TRUE, use an arrow in pointing to the anchor

legend_position

character. Where should the strata labels be located? Either 'inside' for inside the plot, or 'top', or 'right'

legend_anchor_y

numeric. Y locations of anchors for legends. Only used if legend_position = "inside"

legend_nudge_y

numeric.

legend_position_x

numeric. X position of the legend(s)

xlim

numeric.

x_breaks

numeric. Major breaks for the x-axis

label_size

numeric. Size of the labels.

label_color

character. Color of labels.

median_flag_nudge_y

numeric. Amount to nudge median label.

median_flag_thickness

numeric. Thickness of the flag border

risk_table

logical. If TRUE, include the risk table

risk_table_title

character. Title for the risk table

risk_size

numeric. Size of font in risk table.

risk_label_size

numeric. Size of labels in risk table

index_title

character.

event_title

character.

median_flag_size

numeric.

event_nudge_y

numeric.

panel_heights

numeric. Heights of the KM and Risk panels

...

currently ignored

Value

ggplot2

Examples

# Set things up by creating an iwillsurvive x

cohort <- cohort_raw %>%
  derive_followup_date(
    event_date = "dateofdeath",
    censor_date = "lastvisitdate"
  ) %>%
  derive_followup_time(index_date = "lotstartdate") %>%
  derive_event_status(event_date = "dateofdeath")

cohort_iws <- iwillsurvive(cohort,
  followup_time = "followup_days",
  terms = "condition",
  event_title = "Death",
  index_title = "LOT1 Start"
)

# Default plot
plot(cohort_iws)

# Simpler version
plot(cohort_iws,
  simple = TRUE,
  risk_table = FALSE,
  add_confidence = FALSE
)

# Customized version
plot(cohort_iws,
  add_confidence = FALSE,
  add_median_delta = FALSE,
  censor_pch = 3,
  censor_size = 5,
  legend_position_x = c(600, 400),
  legend_nudge_y = c(.25, .3),
  median_flag_nudge_y = .15,
  anchor_arrow = TRUE,
  palette = "Dark2",
  title = "My Title",
  subtitle = "My Subttitle",
  risk_table_title = "My Risk Table Title"
)

ndphillips/iwillsurvive documentation built on June 4, 2024, 3 p.m.