# Create a sample data frame using dates
set.seed(42)
n_patients <- 15
treatment_start_dates <- as.Date("2022-01-01") + sample(1:60, n_patients, replace = TRUE)
treatment_durations_days <- sample(60:1000, n_patients, replace = TRUE)
melanoma_study <- data.frame(
Subject_ID = paste("P", 101:(100 + n_patients), sep = ""),
Start_Date = treatment_start_dates,
End_Date = treatment_start_dates + treatment_durations_days,
Best_Response = factor(sample(c("Complete Response", "Partial Response", "Stable Disease", "Progressive Disease"),
n_patients, replace = TRUE, prob = c(0.2, 0.4, 0.3, 0.1))),
Survival_Days = treatment_durations_days + sample(0:300, n_patients, replace = TRUE)
)
head(melanoma_study)
#> Subject_ID Start_Date End_Date Best_Response Survival_Days
#> 1 P101 2022-02-19 2024-01-01 Stable Disease 826
#> 2 P102 2022-02-07 2023-09-21 Partial Response 699
#> 3 P103 2022-01-02 2023-04-16 Complete Response 665
#> 4 P104 2022-01-26 2024-08-24 Partial Response 944
#> 5 P105 2022-01-11 2024-08-06 Partial Response 1163
#> 6 P106 2022-02-06 2024-09-21 Progressive Disease 1172
# This code simulates how the jamovi module would be called in an R environment.
# You would need the ClinicoPathDescriptives package installed.
# Load the library
library(ClinicoPath)
#> Registered S3 method overwritten by 'future':
#> method from
#> all.equal.connection parallelly
#> Warning: replacing previous import 'dplyr::select' by 'jmvcore::select' when
#> loading 'ClinicoPath'
#> Warning: replacing previous import 'cutpointr::roc' by 'pROC::roc' when loading
#> 'ClinicoPath'
#> Warning: replacing previous import 'cutpointr::auc' by 'pROC::auc' when loading
#> 'ClinicoPath'
#> Warning: replacing previous import 'magrittr::extract' by 'tidyr::extract' when
#> loading 'ClinicoPath'
#> Warning in check_dep_version(): ABI version mismatch:
#> lme4 was built with Matrix ABI version 1
#> Current Matrix ABI version is 0
#> Please re-install lme4 from source or restore original 'Matrix' package
#> Warning: replacing previous import 'jmvcore::select' by 'dplyr::select' when
#> loading 'ClinicoPath'
#> Registered S3 methods overwritten by 'ggpp':
#> method from
#> heightDetails.titleGrob ggplot2
#> widthDetails.titleGrob ggplot2
#> Warning: replacing previous import 'DataExplorer::plot_histogram' by
#> 'grafify::plot_histogram' when loading 'ClinicoPath'
#> Warning: replacing previous import 'ROCR::plot' by 'graphics::plot' when
#> loading 'ClinicoPath'
#> Warning: replacing previous import 'dplyr::select' by 'jmvcore::select' when
#> loading 'ClinicoPath'
#> Warning: replacing previous import 'tibble::view' by 'summarytools::view' when
#> loading 'ClinicoPath'
# Run the swimmer plot analysis using the new, correct arguments
results <- swimmerplot(
data = melanoma_study,
patientID = "Subject_ID",
start = "Start_Date",
end = "End_Date",
event = "Best_Response",
sortVariable = "Survival_Days",
timetype = "datetime",
timetypeoutput = "months",
referenceLines = "custom",
customReferenceTime = 24,
milestone1Date = NULL,
milestone2Date = NULL,
milestone3Date = NULL,
milestone4Date = NULL,
milestone5Date = NULL
)
# The result is a plot image.
print(results$plot)

#> TableGrob (2 x 1) "arrange": 2 grobs
#> z cells name grob
#> 1 1 (1-1,1-1) arrange gtable[layout]
#> 2 2 (2-2,1-1) arrange gtable[layout]