# Plot time-dependent ROC curves using lung dataset from survival package
library(survival)
data(cancer, package = "survival")
# Use age as the marker variable, plot at 6, 12, and 24 months
lung$status <- lung$status == 2
result <- time_roc_plot(lung, "time", "status", "age", times = c(180, 365, 730))
result$plot
# Save the plot to a file
# time_roc_plot(lung, "time", "status", "age", times = c(180, 365, 730), save_plot = TRUE)
Run the code above in your browser using DataLab