R: Survival Curves of Grouped Data sets

ggsurvplot_group_by {survminer} | R Documentation

## Survival Curves of Grouped Data sets

### Description

Survival curves of grouped data sets by one or two variables.

Survival analysis are often done on subsets defined by variables in the dataset. For example, assume that we have a cohort of patients with a large number of clinicopathological and molecular covariates, including survival data, TP53 mutation status and the patients' sex (Male or Female).

One might be also interested in comparing the survival curves of Male and Female after grouping (or splitting ) the data by TP53 mutation status.

`ggsurvplot_group_by`() provides a convenient solution to create a multiple ggsurvplot of a data set grouped by one or two variables.

### Usage

    ggsurvplot_group_by(fit, data, group.by, ...)

### Arguments

`fit` | a survfit object.
`data` | a data frame used to fit survival curves.
`group.by` | a character vector containing the name of grouping variables. Should be of length <= 2.
`...` | ... other arguments passed to the core function `ggsurvplot`.

### Details

`ggsurvplot_group_by`() works as follow:

1. Create a grouped data sets using the function `surv_group_by()`, –> list of data sets

2. Map `surv_fit()` to each nested data –> Returns a list of survfit objects

3. Map `ggsurvplot()` to each survfit object –> list of survfit ggsurvplots

One can (optionally) arrange the list of ggsurvplots using `arrange_ggsurvplots()`

### Value

Retuns a list of ggsurvplots.

### Examples

    # Fit survival curves
    #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    library(survival)
    fit <- survfit( Surv(time, status) ~ sex, data = colon )

    # Visualize: grouped by treatment rx
    #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    ggsurv.list <- ggsurvplot_group_by(fit, colon, group.by = "rx", risk.table = TRUE,
                                     pval = TRUE, conf.int = TRUE, palette = "jco")
    names(ggsurv.list)

    # Visualize: grouped by treatment rx and adhere
    #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    ggsurv.list <- ggsurvplot_group_by(fit, colon, group.by = c("rx", "adhere"),
                                     risk.table = TRUE,
                                     pval = TRUE, conf.int = TRUE, palette = "jco")

    names(ggsurv.list)

[Package survminer version 0.4.1 Index]