Visualizing Long Island Rail Road On-Time Performance With Shiny

Posted on Feb 3, 2019


As a Long Island Rail Road (LIRR) commuter for many years, I've experienced frustrating delays, cancellations and terminations. I wanted to investigate if my branch, Port Jefferson, was more prone to performance issues than other branches. I further set out to discover if On-Time Performance (OTP) is associated with time of year and how OTP has developed over the past decade. Since other commuters may have similar interests, I've created an interactive web application to visualize performance data.


The dataset was gathered from and comes from the MTA’s Performance Dashboard. The data is used to increase transparency at the MTA. Key Performance Indicators (KPI) are used to track performance in areas such as OTP. OTP is defined as the percent of commuter trains that arrive at their destinations within 5 minutes and 59 seconds of their scheduled arrival time.

Application Features & Results

In the Yearly OTP By Branch tab, a user can select any year over the past decade to visualize how a branch performed in a given year and compare to other branches. Alternatively, a user can select the Overall OTP By Branch tab to visualize the average performance of all branches over the past decade.

From the Overall OTP By Branch comparison chart, the Port Jefferson branch is the lowest performer of the past decade with a 89.97% OTP. This means that more than one in ten trains are either delayed, cancelled or terminated on average during the given time period.

To investigate if OTP is associated with time of year or to visualize how OTP has developed over the past ten years, a user can select a branch from a drop down menu and the corresponding plots will update accordingly giving a trend-line.

According to the data, the Port Jefferson branch represented by the blue trend-line on average performs best during April and worst during November. The best performing year of the past decade was 2009 and the worst was 2015. Looking at the overall performance of the LIRR over the past decade represented by the red trend-line, a distinct downward trend is observed indicating that performance is decreasing over time. Since 2009, the average overall OTP has decreased by nearly five percent. With nearly 250,000 scheduled trains per year, that is an annual increase of nearly 12,500 trains delayed, cancelled or terminated.

Additional Insights

After visualizing branch OTP over the past decade, the worst performing branches appeared to have the longest track distances and largest number of stations. Conversely, the best performing branches appeared to be have the shortest track distances and least number of stations. It seemed reasonable to hypothesize that as track distance increases and/or number of stations increase, that the opportunity to accumulate delays would also be greater. To visualize this relationship, I plotted OTP as a function of track distance and number of stations under the Performance Association tab. According to the data, it appears branches with less track distance typically perform better than those with more track distance. Similarly, branches with fewer stations typically perform better than those with a greater number of stations.

Future Work

As a commuter who typically takes the same trains each day, I am more interested to know how my particular train performs in comparison to the rest of the branch and LIRR. The dataset available from did not provide enough information to illustrate such granularity. However, MTA releases information each month on their website illustrating all delayed and cancelled trains with individual train tags. I intend to web-scrape this data and add a tab where a user can select their particular train to obtain OTP statistics.

The LIRR OTP application can be accessed here:

About Author

Joseph C. Fritch

Data Scientist and Control Systems Engineer with 5 years experience in the energy analysis and building automation space. Interests include machine learning and its applications in controlling dynamic systems.
View all posts by Joseph C. Fritch >

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp