options(htmltools.dir.version = FALSE) library(xaringan) library(xaringanthemer) library(tidyverse) source('create_status_tables.R')
library(xaringanthemer) style_duo_accent( primary_color = "#292077" , secondary_color = "#8c54fc", inverse_header_color = "#FFFFFF" )
class: header_background
In clinical trials, a CONSORT diagram shows the flow of participants from screening to analysis, while identifying and providing reasons for dropout or exclusion of participants at each step along the way.
class: header_background
.pull-left[
CONSORT = Consolidated Standards of Reporting Trials, developed by the CONSORT group, http://www.consort-statement.org, which started in 1993 to improve the quality of reporting of clinical trials.
]
.pull-right[
]
class: header_background
class: header_background, center
knitr::include_graphics("images/rpubs_consort.png")
class: header_background
This is still being done by hand, not reproducible
I would like to make this programmatic
class: header_background
any # of arms from 2 to 8 (or more)
can control text wrap with \n
or str_wrap(25)
fits boxes to height, width of text
creates lines and arrows to box center edges
sets standard vertical and horizontal spacing between boxes, lines
creates plot area sufficient to contain diagram
then draws the diagram
class: header_background
class: header_background
class: header_background
class: header_background
One row per candidate participant, with their status at each step of the study
Includes both:
candidate participants excluded (aka screen failures)
(optional) column - studyid
randomized
- Yes or NAexc_reason
- Text or NAarm
- Text per Arm or NArecieved_int
- Yes or NAdnr_int_reason
- Text or NAcompleted
- Yes or NAdiscontinued_reason
- Text or NAanalyzed
- Yes or NAnot_an_reason
- Text or NAclass: header_background
I built examples from actual clinical trials, numbered by # of arms
status2 - (Indomethacin vs Placebo)
class: header_background
glimpse(status2)
class: header_background
- Then ggplot
ggplot(top_tbl) + geom_rect(aes(xmin = xmin, xmax=xmax, ymin=ymin, ymax=ymax)) + geom_text(aes(x=xcenter, y = ycenter, label= label)) + geom_segment(aes(x=x, xend=xend, y=y, yend=yend))
class: header_background
- Then ggplot
ggplot(bottom_n_tbl) + geom_rect(aes(xmin = xmin, xmax=xmax, ymin=ymin, ymax=ymax)) + geom_text(aes(x=xcenter, y = ycenter, label= label)) + geom_segment(aes(x=x, xend=xend, y=y, yend=yend))
class: header_background
count_arms, list_arms
for individual labels: filter and count #, glue to text for each box
for complex labels: count exclusions, build mini-table, add total row, move to top line, collapse to text string with newlines
Does not handle zeroes well (no discontinuations)
build top_tbl
(in progress) build bottom_n_tbl
class: header_background
There is no way I could maintain a package alone.
Help needed
class: header_background
.center[ https://github.com/higgi13425/ggconsort ]
knitr::include_graphics("images/github-ggconsort.png")
class: header_background
knitr::include_graphics("images/hex-ggconsort.png")
class: header_background
class: inverse, center, middle
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.