# fit KM
km_fit <- survival::survfit(survival::Surv(AVAL, 1 - CNSR) ~ TRTP, data = adtte)
# plot curves using survival plot function
plot(km_fit)
# plot same curves using visR::visr plotting function
visR::visr(km_fit)
# estimate KM using visR wrapper
survfit_object <- visR::estimate_KM(data = adtte, strata = "TRTP")
# Plot survival probability
visR::visr(survfit_object, fun = "surv")
# Plot survival percentage
visR::visr(survfit_object, fun = "pct")
# Plot cumulative hazard
visR::visr(survfit_object, fun = "cloglog")
## Create attrition
attrition <- visR::get_attrition(adtte,
criteria_descriptions = c(
"1. Not in Placebo Group",
"2. Be 75 years of age or older.",
"3. White",
"4. Female"
),
criteria_conditions = c(
"TRTP != 'Placebo'",
"AGE >= 75",
"RACE=='WHITE'",
"SEX=='F'"
),
subject_column_name = "USUBJID"
)
## Draw a CONSORT attrition chart without specifying extra text for the complement
attrition %>%
visr("Criteria", "Remaining N")
## Add detailed complement descriptions to the "exclusion" part of the CONSORT diagram
# Step 1. Add new column to attrition dataframe
attrition$Complement <- c(
"NA",
"Placebo Group",
"Younger than 75 years",
"Non-White",
"Male"
)
# Step 2. Define the name of the column in the call to the plotting function
attrition %>%
visr("Criteria", "Remaining N", "Complement")
## Styling the CONSORT flowchart
# Change the fill and outline of the boxes in the flowchart
attrition %>%
visr("Criteria", "Remaining N", "Complement", fill = "lightblue", border = "grey")
## Adjust the font size in the boxes
attrition %>%
visr("Criteria", "Remaining N", font_size = 10)
Run the code above in your browser using DataLab