ggRD: Plot risk differences over time with ggplot2

Description Usage Arguments Value Author(s)

View source: R/ggsurv.R

Description

This function produces plots of risk differences over time using ggplot2. As a first argument it needs a dataset of risk differences produced by link{get_RDs}. See http://ggobi.github.io/ggally/#ggallyggsurv for additional modifications of the resulting output plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
ggRD(
  RDests,
  CI = TRUE,
  CI_errorbar = FALSE,
  CI_line = FALSE,
  plot_cens = TRUE,
  surv_col = "gg.def",
  cens_col = "gg.def",
  lty_est = 1,
  shape_est = seq_along(RDests),
  lty_ci = 2,
  size_est = 0.5,
  size_ci = size_est,
  size_pt = size_est + 0.3,
  cens_size = 2,
  cens_shape = 3,
  back_white = TRUE,
  xlab = "Time",
  ylab = "Risk Difference",
  main = "",
  legend_pos = "right",
  RD_name = "RD",
  SE_name = "RD.SE",
  CIlow_name = "CI95low",
  CIup_name = "CI95up",
  order_legend = TRUE,
  t_int_sel = NULL,
  ymin = NULL,
  ymax = NULL,
  facet = FALSE,
  font_size = 6,
  line_RD_plot = TRUE,
  x_breaks = unique(RDests[["time"]]),
  axis_font_size = NULL,
  x_axis_font_angle = 0,
  ...
)

Arguments

RDests

A table in long format with a single column containing names of two contrasting regimens. Each list item must be a data.frame containing the risk difference estimates over time.

CI

should a 95% confidence interval be plotted? Defaults to TRUE. Uses the standard error RDests provided as a separate column of the input data.

CI_errorbar

Plot CIs as error bars around point estimates, default is FALSE.

CI_line

When TRUE the 95% CIs will be plotted as a line function (same as main plot type). When FALSE the 95% CIs are plotted using ggplot2::geom_ribbon.

plot_cens

mark the censored observations?

surv_col

colour of the survival estimate. Defaults to black for one stratum, and to the default ggplot2 colours for multiple strata. Length of vector with colour names should be either 1 or equal to the number of strata.

cens_col

colour of the points that mark censored observations.

lty_est

linetype of the survival curve(s). Vector length should be either 1 or equal to the number of strata.

shape_est

shape type of the survival point RDests. Vector length should be either 1 or equal to the number of strata.

lty_ci

linetype of the bounds that mark the 95% CI.

size_est

line width of the survival curve

size_ci

line width of the 95% CI

size_pt

point size of the survival estimate at each time-point

cens_size

point size of the censoring points

cens_shape

shape of the points that mark censored observations.

back_white

if TRUE the background will not be the default grey of ggplot2, but will be white with borders around the plot. Defaults to TRUE

xlab

the label of the x-axis.

ylab

the label of the y-axis.

main

the plot label.

legend_pos

Either the coordinates of the legend position inside the plot (e.g., (0.9, 0.2)) or the character word denoting the legend orientation with respect to the plot (e.g., "bottom", "right" or "left").

RD_name

The name of the column containing the risk differences.

SE_name

The name of the column containing the standard errors (SE) for each risk difference.

CIlow_name

The name of the column containing the lower bound of the confidence interval (optional).

CIup_name

The name of the column containing the upper bound of the confidence interval (optional).

order_legend

Set to TRUE to order the legend display by final survival time (highest first).

t_int_sel

The subset of time-point indices for which survival should be plotted.

ymin

The minimum value of the y axis. The default (ymin=NULL) is to use ggplot to automatically adjust the limits of the y-axis.

ymax

The maximum value of the y axis. The default (ymax=NULL) is to use ggplot to automatically adjust the limits of the y-axis.

facet

Set to TRUE to create a facet of plots by first / last tx name

font_size

Font size for facet labels, legend text and legend title.

line_RD_plot

Connect the point risk differences with a plotted line (using geom_line).

x_breaks

Vector of breaks to display on x-axis

axis_font_size

Control the font size of x and y axis, leave as NULL for default.

x_axis_font_angle

Control the angle of rotation for x-axis labels (default is 0).

...

Additional arguments (not used).

Value

An object of class ggplot

Author(s)

Original R code by Edwin Thoen edwinthoen@gmail.com, modified by Oleg Sofrygin oleg.sofrygin@gmail.com


osofr/estimtr documentation built on Jan. 25, 2022, 8:05 a.m.