You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
df <- lung %>%
transmute(time,
status, # censoring status 1=censored, 2=dead
Age = age,
Sex = factor(sex, labels = c("Male", "Female")),
ECOG = factor(lung$ph.ecog),
`Meal Cal` = as.numeric(meal.cal))
vars <- c("ECOG", "Sex")
surv_plot_func <- function(df, vars, time, status) {
# fit_list <- list()
for(var in vars) {
form <- paste0("Surv(", time, ", ", status,") ~ ",var)
fit <- survfit(as.formula(form), data=df)
ggsurvplot(fit)
# plot(fit)
# fit_list[[var]] <- fit
}
surv_plot_func(df, vars, "time", "status")
However, error Error in as.formula(form) : object 'form' not found is printed. I guess error keeps occurring in ggsurvplot().
How could I handle this error?
I'm trying to solve a problem from stackoverflow.
Here's the code I've tried.
However, error
Error in as.formula(form) : object 'form' not found
is printed. I guess error keeps occurring inggsurvplot()
.How could I handle this error?
Below is the
traceback()
of the code.session_info()
The text was updated successfully, but these errors were encountered: