get_logrank_res: Run Log-Rank Test

Description Usage Arguments Value Examples

Description

get_logrank_res is a wrapper over the survival::survdiff() function return the direct results or the log rank p-value only if specified.

Usage

1
get_logrank_res(in.formula, in.df, return.p = FALSE)

Arguments

in.formula

Survival model formula. Can extract from an existing survfit object with formula(survfit).

in.df

data.frame Corresponding data for the survival model.

return.p

If set to TRUE, return only the log rank p-value.

Value

Results of survdiff or a log rank p-value if return.p is set to TRUE.

Examples

1
2
3
4
5
6
7
8
library("survival")
 
# Get survdiff results
fit <- survfit(Surv(time, status) ~ rx, data = colon)
get_logrank_res(formula(fit), colon)

# Get only log-rank p-value
get_logrank_res(formula(fit), colon, return.p = TRUE)

Example output

Call:
survival::survdiff(formula = in.formula, data = in.df)

             N Observed Expected (O-E)^2/E (O-E)^2/V
rx=Obs     630      345      299      7.01     10.40
rx=Lev     620      333      295      4.93      7.26
rx=Lev+5FU 608      242      326     21.61     33.54

 Chisq= 33.6  on 2 degrees of freedom, p= 5e-08 
[1] 4.990735e-08

survutils documentation built on May 2, 2019, 6:38 a.m.