-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi,
Thanks for this very nice package.
Would it be possible to add default values in plot_surv_area()?
You will often use the same values as the ones you used in the model.
Therefore, you could write a much simpler code to get the same output.
If you think about putting model as the first argument, your function even becomes pipeable! (At the price of backward compatibility, though)
library(survival)
library(contsurvplot)
#> Warning: le package 'contsurvplot' a été compilé avec la version R 4.4.3
#> Please cite as:
#>
#> Denz R, Timmesfeld N (2023). "Visualizing the (Causal) Effect of a Continuous Variable on a Time-To-Event Outcome." Epidemiology, 34 (5). doi: 10.1097/EDE.0000000000001630.
plot_surv_area2 = function(model, variable, data, time, status, ...) {
if(missing(data)) data <- eval(model$call$data, envir=parent.frame())
surv_var = all.vars(formula(model))
if(missing(time)) time=surv_var[1]
if(missing(status)) status=surv_var[2]
if(missing(variable)) variable=surv_var[3]
plot_surv_area(time=time,
status=status,
variable=variable,
data=data,
model=model, ...)
}
coxph(Surv(time, status) ~ age + sex + nodes, data=colon, x=TRUE) %>%
plot_surv_area2(variable="nodes")Created on 2025-03-05 with reprex v2.1.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
