The Timeline Explorer is a Shiny application built in R that provides an intuitive and interactive way to visualize time-based relationships between multiple events in large datasets. It enables users to explore patterns, trends, and key insights by dynamically interacting with the data.
The Timeline Explorer Plot is a powerful interactive visualization tool that offers the following features:
-
Event Representation Over Time
A horizontal timeline displays time points, and events are positioned along this axis to illustrate their occurrence or duration.
-
Comparative Analysis Events can be compared relative to a specific reference event, uncovering relationships and patterns over time.
-
Interactive Exploration • Zoom in/out and scroll through time. • Hover over specific data points for detailed information. • Examine event trends with dynamic controls.
-
Dynamic Insights This visualization enables deeper understanding through interactive exploration of event-based data, such as identifying clusters, trends, or outliers.
-
R Shiny Integration The application leverages R Shiny to provide an easy-to-use interface for building interactive timeline visualizations.
The Timeline Explorer Shiny App uses R’s interactive web framework to deliver:
-
User-Friendly Interaction
• Collect input values through an intuitive web interface.
• Dynamically display results based on user interaction.
-
Versatile Deployment Options
• Host standalone applications on a webpage.
• Embed interactive charts in R Markdown documents.
• Build dashboards for a comprehensive view of data.
-
Simple Architecture
• UI (User Interface): Defines how the app looks and collects user inputs.
• Server Script: Executes R code and sends results back to the user interface.
To generate the data for the timeline visualization:
-
Required Variables
• Patient_ID: Unique identifier for each patient.
• Event Classification: Types of events (e.g., diagnosis, treatment, etc.).
• Event Date: Date when the event occurred.
-
Rules for Data Preparation
• If multiple dates exist for the same event, the first of them will be selected for the index, others will be shown in the plot.
The app uses this prepared events table to create a dynamic timeline plot, enabling users to:
-
View heatmaps showing event frequency and distribution over time.
-
Compare events across categories relative to a reference event.
-
Analyze data with visual markers for median timing and annotated occurrence counts.
The app.R script performs the following tasks:
-
Data Preparation
• Loads the events dataset.
• Identifies the first occurrence of each event for every patient.
• Filters out patients with a “Diagnosis” event that occurred after other events.
-
Interactive Visualization
• Allows users to select events for visualization.
• Displays two interactive timeline plots:
• Heatmap: Frequency and distribution of events over time.
• Timeline Plot: Insights into median timings and annotated occurrences.
-
Clone this repository to your local machine.
-
Open the app.R file in RStudio or another IDE.
-
Run the app using the Shiny framework:
shiny::runApp("app.R")
- Interact with the timeline visualizations to explore your data.
This Shiny app provides a robust solution for exploring event-based data, helping users identify meaningful patterns and insights with ease.
-
After running the R Shiny app code, the window appears as shown in the snippet below

-
Select the event from the drop down box to get the timeline explorer plot for the specific event

-
We can zoom the required portion of the plot for better visualization. Red portion in the plot represents the maximum number of patients had the event at that timepoint
