---
title: "Generic exclusion flow charts"
author: "Jack O. Wasey"
date: "`r Sys.Date()`"
output:
  rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Generic exclusion flow charts}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

PRISMA flow charts are a special case of a common plot used in clinical research. There are many examples where a population is whittled down to a study group, and, in good reports, the process is described. A flow chart is an effective way of presenting this data.

```{r setup, include = FALSE}
library(PRISMAstatement)
suppressPackageStartupMessages(library(DiagrammeR))
knitr::opts_chunk$set(
  collapse = TRUE,
  fig.width = 3
  )
```

```{r genericflowexamples, fig.cap = "Fictitious study data, presenting just counts"}
flow_exclusions(
  incl_counts = c(972, 132, 77, 14),
  total_label = "Total Screened",
  incl_labels = c("Consented", "Completed Study", "BMI <= 30"),
  excl_labels = c("Declined Consent", "Failed to Complete", "BMI > 30")
)
```

```{r percoftotal, fig.cap = "Percentages of the Total figure"}
flow_exclusions(c(1000, 300, 150, 75, 38), percent_of_total = TRUE)
```

```{r percofprev, fig.cap = "Percentages of the previous box"}
flow_exclusions(c(100000, 3000, 1666, 411, 38),
                percent_of_prev = TRUE,
                show_count = FALSE)
```

```{r genericflowexamples2, fig.cap = "Demonstrating other options"}
flow_exclusions(
  incl_counts = c(972, 132, 77, 14),
  total_label = "Total Screened",
  incl_labels = c("Consented", "Completed Study", "BMI <= 30"),
  excl_labels = c("Declined Consent", "Failed to Complete", "BMI > 30"), 
  percent_of_total = TRUE,
  percent_of_prev = FALSE,
  show_count = FALSE,
  font_size = 14)
```
