Motor vehicle collisions in New York City – R / Shiny Data Visualization

July 6, 2017
By

(This article was first published on R – NYC Data Science Academy Blog, and kindly contributed to R-bloggers)

Introduction

Shiny by RStudio is a web application framework targeted for R programmers. It allows our analysis to be extended as an interactive web application  that can be quickly developed and deployed using RStudio. The post presents how vast amount of data is easily filtered and used as input to the visualizations that were developed.

Data Source

The data that has been published under the New York open data project contains details of all motor vehicle collisions and related data including location and timing information as well as details of the vehicle involved in the collision and the root cause. The data can be accessed at https://data.cityofnewyork.us/Public-Safety/NYPD-Motor-Vehicle-Collisions/h9gi-nx95

The source data consists of around 948,000 records and by designing a shiny based interface to filter data with the goal of finding trends.

The Shiny Interface

The user interface has been designed such that the left side contains a bar that contains radio buttons and filter controls that lets the user filter the data according to our analysis needs.

Filter Control

ui-control

The interface lets us filter the data according to our needs.

Tabbed Detail Interface – Data Visualization

The tabbed detail interface lets the user view various types of visualizations that were created based on the filtered data. For e.g., it lets the user see the accidents based on the hour of the day it happened. Selecting another tab lets you see the same data on top if a map.

hourofincident

Spread of the accidents based on the day of the week.

weekofthedayplot

 

 

Accident density based on the month of the year.

monthlydistribution

Accidents mapped on top of a map of New York City.

locationsofincidents

Summarized information based on the density of accidents across NYC

accidentdensity

Detailed information related to the data records that are filtered based on the selected controls.

datatableview

Visualization depicting the type of the vehicles involved in the accidents.

singlevehicleaccidentvehicletype

Based on an alternate filter, we see that the shiny app allows the user to see the same graph based on the new filter selection.

multivehiclevehicletypes

 

Conclusion

Shiny application is a quick way to allow business users to have greater control over the data. The visualization that we develop can be deployed in such a way that it allows users greater control over the capability. The reports can be regenerated based on their needs.

 

The post Motor vehicle collisions in New York City – R / Shiny Data Visualization appeared first on NYC Data Science Academy Blog.

To leave a comment for the author, please follow the link and comment on their blog: R – NYC Data Science Academy Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)