Creates professional study flow diagrams including CONSORT diagrams and flowcharts using multiple rendering engines
Usage
studydiagram(
  data,
  data_format = "participant_step",
  diagram_type = "consort_standard",
  participant_id,
  step_excluded,
  exclusion_reason_participant,
  step_name,
  participant_count,
  exclusion_reason_summary,
  participant_id_mapping,
  exclusion_reason_mapping,
  step1_exclusions,
  step2_exclusions,
  step3_exclusions,
  step4_exclusions,
  step5_exclusions,
  step1_label = "Screening",
  step2_label = "Enrollment",
  step3_label = "Treatment",
  step4_label = "Follow-up",
  step5_label = "Analysis",
  show_percentages = FALSE,
  show_exclusion_boxes = FALSE,
  direction = "TB",
  color_scheme = "gray",
  show_interpretation = FALSE
)Arguments
- data
- The data as a data frame. 
- data_format
- How your data is structured. Participant tracking: each row is a participant with step excluded. Step summary: each row is a study step with counts. Exclusion mapping: map exclusion reasons to steps. 
- diagram_type
- Rendering engine and diagram style. CONSORT for clinical trials, Flowchart for general study flows. Standard uses DiagrammeR, ggplot2 uses modern styling. 
- participant_id
- Variable identifying individual participants (for participant tracking format) 
- step_excluded
- Variable indicating at which step number the participant was excluded (for participant tracking format) 
- exclusion_reason_participant
- Variable containing exclusion reason text (for participant tracking format) 
- step_name
- Variable containing step/stage names (for step summary format) 
- participant_count
- Variable containing participant counts at each step (for step summary format) 
- exclusion_reason_summary
- Variable containing exclusion reason descriptions (for step summary format) 
- participant_id_mapping
- Variable identifying individual participants (for exclusion mapping format) 
- exclusion_reason_mapping
- Variable containing all exclusion reasons (for exclusion mapping format) 
- step1_exclusions
- Select exclusion reason levels that occur at step 1 
- step2_exclusions
- Select exclusion reason levels that occur at step 2 
- step3_exclusions
- Select exclusion reason levels that occur at step 3 
- step4_exclusions
- Select exclusion reason levels that occur at step 4 
- step5_exclusions
- Select exclusion reason levels that occur at step 5 
- step1_label
- Label for step 1 in the diagram 
- step2_label
- Label for step 2 in the diagram 
- step3_label
- Label for step 3 in the diagram 
- step4_label
- Label for step 4 in the diagram 
- step5_label
- Label for step 5 in the diagram 
- show_percentages
- Show percentage of initial participants retained at each step 
- show_exclusion_boxes
- Show side boxes with exclusion counts and reasons 
- direction
- Direction of diagram flow 
- color_scheme
- Color scheme for diagram elements 
- show_interpretation
- Show explanatory text about the generated diagram 
Value
A results object containing:
| results$todo | Instructions and data format guidance | ||||
| results$summary | Summary of participant flow through study steps | ||||
| results$diagram | Interactive study flow diagram | ||||
| results$plot | Publication-ready diagram plot | ||||
| results$interpretation | Explanatory text about the diagram and results | ||||
| results$warnings | Alerts about potential data quality issues | ||||
| results$clinicalSummary | Plain-language summary for clinical interpretation | ||||
| results$reportSentence | Copy-ready sentence for manuscripts | ||||
| results$aboutAnalysis | Explanation of analysis type and usage | ||||
| results$caveatsAssumptions | Important considerations and limitations | 
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$summary$asDF
as.data.frame(results$summary)