openpharma / visR

A package to wrap functionality for plots, tables and diagrams adhering to graphical principles.
https://openpharma.github.io/visR/
Other
179 stars 31 forks source link

generating kaplan-meier table/plot without strata #59

Closed kzalocusky closed 4 years ago

kzalocusky commented 4 years ago

Issue description

I'm hoping to generate kaplan-meier plots/tables without stratifying my population. My equation looks like this: surv_eq <- "survival::Surv(time, status)~1"

Steps to reproduce the issue

Please share code if possible.

surv_eq <- "survival::Surv(time, status)~1"

vr_kaplan_meier_summary(km_dt, surv_eq)

vr_kaplan_meier(km_dt, surv_eq)

What's the expected result?

I get back a summary table if I supply "ms_subtype" rather than "1" as the strata. For possibly unrelated reasons, I'm unable to generate a kaplan-meier plot even with strata supplied (see below).

What's the actual result?

vr_kaplan_meier_summary() generates this error if I do not supply strata: Error: Column strata must be length 9 (the number of rows) or one, not 0

vr_kaplan_meier_summary() generates the expected tables if I do supply strata.

vr_kaplan_meier() generates this error if I do not supply strata: Error in data.frame(time = survfit_summary$time, n.risk = survfit_summary$n.risk, : arguments imply differing number of rows: 43, 0

vr_kaplan_meier() generates this error if I do supply strata: Error in summarize(., max_time = max(time)) : argument "by" is missing, with no default

Additional details / screenshot

SHAESEN2 commented 4 years ago

I can take on this issue.

SHAESEN2 commented 4 years ago

The issue is now fixed in development. Use vr_KM_est(data = data, strata = NULL). Mind that the time variable is expecting to be named 'AVAL' and the censoring variable 'CNSR' with 1 = censored.