View source: R/ctg_data_report.R
ctg_data_report | R Documentation |
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.
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
)
ctg_data |
A data frame containing clinical trial data. Required columns include:
|
title |
Character string. The title of the report.
Default is |
author |
Character string. The name of the report author.
Default is |
output_file |
Character string. The file path where the HTML report will be saved.
Default is |
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 |
include_data_quality |
Logical. Whether to include a data quality assessment section.
Default is |
include_interactive_plots |
Logical. Whether to generate interactive plots using plotly.
Default is |
custom_footer |
Character string or |
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.
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.
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.
https://www.indraneelchakraborty.com/clintrialx/ for more information about the ClinTrialX package.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.