Generate a Comprehensive Clinical Trial Data Report
ctg_data_report.Rd
This function creates a detailed, visually appealing HTML report from clinical trial data. It automates the process of data analysis and visualization, providing insights into various aspects of clinical trials such as study status, enrollment, duration, and funding sources.
Visit here for an example report - https://www.indraneelchakraborty.com/clintrialx/report.html.
Usage
ctg_data_report(
ctg_data,
title = "Clinical Trial Data Report",
author = "Author Name",
output_file = "./report.html",
color_palette = c("#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b"),
theme = "cerulean",
include_data_quality = TRUE,
include_interactive_plots = TRUE,
custom_footer = NULL
)
Arguments
- ctg_data
A data frame containing clinical trial data. Required columns include:
Study Status
: Current status of each study (e.g.,"Completed"
,"Ongoing"
)Enrollment
: Number of participants in each studyStart Date
: The date each study beganCompletion Date
: The date each study ended or is expected to endPhases
: The phase of each clinical trial (e.g.,"Phase 1"
,"Phase 2"
)Funder Type
: The type of organization funding each studyStudy Type
: The type of each study (e.g.,"Interventional"
,"Observational"
)
- title
Character string. The title of the report. Default is
"Clinical Trial Data Report"
.Character string. The name of the report author. Default is
"Author Name"
.- output_file
Character string. The file path where the HTML report will be saved. Default is
"./report.html"
. You can specify a different path if needed.- color_palette
Character vector. A set of colors to be used in the report's visualizations. Default is a preset palette of 6 colors. You can provide your own color codes for customization.
- theme
Character string. The Bootstrap theme for the HTML report. Default is
"cerulean"
. Other options include"default"
,"journal"
,"flatly"
,"readable"
,"spacelab"
,"united"
,"cosmo"
,"lumen"
,"paper"
,"sandstone"
,"simplex"
, and"yeti"
.- include_data_quality
Logical. Whether to include a data quality assessment section. Default is
TRUE
. Set toFALSE
if you want to skip this section.- include_interactive_plots
Logical. Whether to generate interactive plots using plotly. Default is
TRUE
. Set toFALSE
for static plots, which may be preferred for certain use cases.Character string or
NULL
. A custom footer for the report. IfNULL
(default), a standard footer crediting the ClinTrialX package is used.
Value
This function doesn't return a value, but generates an HTML report at the specified location. It prints a message with the path to the generated report upon successful completion.
Details
The function performs these key steps:
1. Package Management:
Checks for required packages and offers to install any that are missing.
Required packages:
rmarkdown
,ggplot2
,plotly
,dplyr
,lubridate
,reactable
,scales
,RColorBrewer
,htmltools
.
2. Report Generation:
Creates a temporary R Markdown file with the report content.
Includes an executive summary with key statistics.
Provides an interactive data table for easy exploration of the dataset.
3. Data Visualization:
Study Status Distribution: Bar chart showing the count of studies in each status.
Enrollment by Study Phase: Box plot displaying enrollment numbers across different study phases.
Study Duration Timeline: Scatter plot showing the relationship between study start dates and durations.
Funding Sources and Study Types: Stacked bar chart illustrating the proportion of study types for each funder type.
4. Optional Sections:
Data Quality Assessment: Bar chart showing the percentage of missing data for each variable (if enabled).
Interactive Plots: Uses plotly to create interactive versions of all plots (if enabled).
5. Report Finalization:
Renders the R Markdown file to an HTML report.
Cleans up temporary files.
Tips for Users
Ensure your data frame has all required columns before using this function.
Experiment with different themes to find the most suitable look for your report.
If you encounter any package installation issues, you may need to install them manually.
For large datasets, setting
include_interactive_plots = FALSE
may improve performance.Custom color palettes can be used to match your organization's branding.
The generated report is self-contained and can be easily shared or published on the web.
See also
https://www.indraneelchakraborty.com/clintrialx/ for more information about the ClinTrialX package.