vr_plot: Create a 'ggplot' directly from an object through an S3...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/vr_plot.R

Description

S3 method for creating plots directly from objects using 'ggplot2', similar to base plot function. The default method is base::plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
vr_plot(x, ...)

## Default S3 method:
vr_plot(x, ...)

## S3 method for class 'survfit'
vr_plot(
  survfit_object = NULL,
  y_label = NULL,
  x_label = NULL,
  x_units = NULL,
  x_ticks = NULL,
  y_ticks = NULL,
  fun = "surv",
  legend_position = "right"
)

Arguments

x

object to be passed on to the method

...

other arguments passed on to the method

survfit_object

Object of class 'survfit'

y_label

character Label for the y-axis. When not specified, the default will do a proposal, depending on the 'fun' argument.

x_label

character Label for the x-asis. When not specified, the algorithm will look for "PARAM" information inside the list structure of the 'survfit' object. Note that this information is automatically added when using visR::vr_KM_est and when the input data has the variable "PARAM". If no "PARAM" information is available "time" is used as label.

x_ticks

Ticks for the x-axis. When not specified, the default will do a proposal.

y_ticks

Ticks for the y-axis. When not specified, the default will do a proposal based on the 'fun' argument.

fun

Arbitrary function defining a transformation of the survival curve. This argument will also influence the y_ticks and y_label if not specified.

  • "surv": survival curve on the probability scale. The default y label will state "Survival probability".

  • "log": log survival curve. The default y label will state "log(Survival probability)".

  • "event": empirical CDF f(y) = 1-y. The default y label will state "Failure probability".

  • "cloglog": complimentary log-log survival f(y) = log(-log(y)). The default y label will state "log(-log(Survival probability))".

  • "pct": survival curve, expressed as percentage. The default y label will state "Survival probability (%)".

  • "logpct": log survival curve, expressed as percentage. The default y label will state "log(Survival probability (%))".

  • "cumhaz": MLE estimate of the cumulative hazard f(y) = -log(y). The default y label will state "cumulative hazard".

legend_position

Specifies the legend position in the plot. Character values allowed are "top" "left" "bottom" "right". Numeric coordinates are also allowed. Default is "right".

x_unit

Unit to be added to the x_label (x_label (x_unit)). Default is NULL.

Value

Object of class ggplot ggsurvplot.

Author(s)

Steven Haesendonckx

See Also

ggplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(survival)
library(dplyr)
library(tidyr)
library(ggplot2)

survfit_object <- vr_KM_est(data = adtte, strata = "TRTP")

## Plot survival probability
vr_plot(survfit_object = survfit_object, fun = "surv")
vr_plot(survfit_object, fun = "pct")

## Plot cumulative hazard
vr_plot(survfit_object, fun = "cloglog")
 

visR-sandbox/visR-survival documentation built on Sept. 18, 2020, 6:21 p.m.