library(consort)
Consort diagram.
In [1]:
In [2]:
# use https://github.com/adayim/consort
# use the consort package to generate a CONSORT diagram using the indo_rct dataset, much like the picture below
<- 799
N <- sample(c(1000:2000), N)
trialno <- rep(NA, N)
exc1 sample(1:N, 197)] <- sample(c("Did not meet inclusion criteria", "Met exclusion criteria", "Did not undergo ERCP"), 15, replace = TRUE, prob = c(0.858, 0.0558, 0.086)) exc1[
Warning in exc1[sample(1:N, 197)] <- sample(c("Did not meet inclusion
criteria", : number of items to replace is not a multiple of replacement length
<- rep(NA, N)
induc is.na(exc1)] <- trialno[is.na(exc1)]
induc[
<- rep(NA, N)
exc2 sample(1:N, 1)] <- sample(c( "Could not hold suppository"), 1, replace = TRUE, prob = c(0.0039))
exc2[is.na(induc)] <- NA
exc2[
<- rep(NA, N)
arm is.na(exc1)] <- sample(c("Conc", "Seq"), sum(is.na(exc1)), replace = TRUE)
arm[<- sample(c("Indomethacin", "Placebo"), N, replace = TRUE)
arm3 is.na(arm)] <- NA
arm3[
<- data.frame(trialno, exc1, induc, exc2, exc1, arm, arm3)
df_consort rm(trialno, exc1, induc, exc2, exc1, arm, arm3, N)
Warning in rm(trialno, exc1, induc, exc2, exc1, arm, arm3, N): object 'exc1'
not found
consort_plot(
data = df_consort,
order = list(
trialno = "Population",
exc1 = "Excluded",
induc = "Induction",
exc2 = "Excluded",
arm3 = "Randomized patient",
trialno = "Finished Followup",
trialno = "Final Analysis"
),side_box = c("exc1", "exc2"),
allocation = "arm3",
labels = c(
"1" = "Screening", "2" = "Randomization",
"3" = "Assignment", "5" = "End of study"
),cex = 0.7
)