Learn R Programming

survutils (version 1.0.2)

get_logrank_res: Run Log-Rank Test

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

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

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab