survfit_it: multiple survival curves

Description Usage Arguments Value Examples

View source: R/survfit_it.R

Description

wrapper for survfit to create multiple survival curves for multiple endpoints, stratifications and groupings

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
survfit_it(
  surv,
  data,
  strata = NULL,
  glist = NULL,
  w = NULL,
  type = "kaplan-meier",
  prefix = c(event = "ev.", time = "t."),
  vs_age = FALSE,
  age_var = NULL,
  age_bound = NULL,
  progress = FALSE,
  stringsAsFactors = TRUE
)

Arguments

surv

the Surv objects (as character, refering to variables in 'data') OR the common names of time + event, if these have similar names (differing only in perfix)

data

the data

strata

stratifying variable

glist

a grouping list (list of logical vectors of the same length as rows in data, i.e. can be overlapping groups), or the name of a grouping variable in 'data'

w

weight or name of variable that provides weights

type

passed to survival::survfit

prefix

prefix values for times and events

vs_age

logical; should KM curves be with age on the x-axis?

age_var

character; name of age variable. N.B. important that age is measured in the same units as the time variable

age_bound

numeric; what age to start from

progress

primitive displayer of progress

stringsAsFactors

logical, if TRUE will keep ordering of ingoing stuff

Value

a data frame (much like a broom::tidy-version of the output)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
n = 1200
df <- data.frame(
        t.foo = abs(rnorm(n, 10, 2)),
        ev.foo = rbinom(n, 1, 0.2),
        t.bar = abs(rnorm(n, 10, 3)),
        ev.bar = rbinom(n, 1, 0.3),
        strutt = sample(letters[1:2], n, TRUE),
        gsak = sample(LETTERS[4:7], n, TRUE),
        wait = .5 + abs(rnorm(n, 0, 1))
)
str(survfit_it(data = df, surv = c("foo", "bar"), w = "wait",
          strata = "strutt", glist = "gsak"))

renlund/dm documentation built on Jan. 18, 2022, 9:50 a.m.