add_annotation: Wrapper around ggplot2::annotation_custom for simplified...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/add_annotation.R

Description

This function accepts a string, dataframe, data.table, tibble or customized objects of class gtable and places them on the specified location on the ggplot. The layout is fixed: bold columnheaders and plain body. Only the font size and type can be chosen.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
add_annotation(
  gg = NULL,
  lbl = NULL,
  base_family = "sans",
  base_size = 11,
  xmin = -Inf,
  xmax = Inf,
  ymin = -Inf,
  ymax = Inf
)

Arguments

gg

Object of class ggplot.

lbl

String, dataframe, data.table, tibble used to annotate the ggplot.

base_family

character. Base font family

base_size

numeric. Base font size in pt

xmin,

xmax x coordinates giving horizontal location of raster in which to fit annotation.

ymin,

ymax y coordinates giving vertical location of raster in which to fit annotation.

Value

Object of class ggplot with added annotation with an object of class gtable.

Author(s)

Steven Haesendonckx

See Also

tableGrob annotation_custom

Examples

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

## Estimate survival
surv_object <- vr_KM_est(data = adtte, strata = "TRTP")

## p value for "Equality across strata"
lbl <- get_pvalue(survfit_object, statlist = c("test", "p"), type = "All")

## add results to survival plot
vr_plot(survfit_object) %>%
  add_annotation(lbl = lbl, base_family = "sans", base_size = 9, xmin = 110, xmax = 180, ymin = 0.80)

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