PLOTCON 2016,NYC
TANYA CASHORALI
@TANYACASH21
BASE R (2000)
2
GGPLOT2 (2007)
3
D3.JS (2011)
4
PLOTLY (2013)
5
RCHARTS (2013)
6
GGVIS (2014)
7
JAVASCRIPT CHARTING LIBRARIES
 D3.js
 Highcharts
 Dygraphs
 FusionCharts
 Sigma.js
 Rickshaw
 Canvas.js
 Ember charts
 NVD3
 Chart.js
8
PLOTLY TO THE RESCUE
9
Pictured Above: Data Science Superhero
D3.JS PIE CHART
10
67 lines of code!
https://bl.ocks.org/mbostock/3887235
PIE CHART IN PLOTLY
11
BAR CHART VERSION IN PLOTLY
12
D3.JS
13
http://bl.ocks.org/mbostock/3884955
98 lines of code!
EQUIVALENT IN R WITH INTERACTIVITY
14
CHART.JS DASHBOARD
15
Online: http://coenraets.org/apps/olympic-dashboard/#dashboard/1
Source Code: https://github.com/ccoenraets/olympic-dashboard-chartjs/blob/master/www/js/dashboard1.js
16
124 lines of just
javascript!!
17
SHINYDASHBOARD + SHINY + PLOTLY
https://tcb-analytics.shinyapps.io/Plotcon2/
18
58 TOTAL LINES OF CODE
ui.R
server.R
FLEXDASHBOARD + SHINY + PLOTLY
19
• https://tcb-analytics.shinyapps.io/Plotcon/
• Data From: http://www.pro-football-reference.com/years/2016/passing.htm
20
68 LINES OF R CODE
JAVASCRIPT EQUIVALENT
 script.js = 82 lines of code
 index.html = ~50 lines of handwritten,
uncompiled code
 Total of 132 lines of code
 Approximately double the dev time, no
scaling of variables
21
Created by: www.brophyanalytics.com
Javascript: https://github.com/tcash21/tcash21.github.io/blob/master/uploads/script.js
22
DEPLOY TO SHINYAPPS.IO IN 2 LINES
rsconnect::setAccountInfo(name='tcb-analytics', token=my_token', secret=my_secret')
deployApp('.', appName='Plotcon2')
• http://flowingdata.com/2016/10/07/learning-r-versus-d3-js-for-visualization/
“I guess it comes back to the original question of what
you ultimately want out of your visualization. For static
graphics, R is a good way to get quick results. For
interactive and web-native graphics, check out d3.js.”
- Nathan Yau, FlowingData
23
USE CASES – PHYSICIAN CLINICAL INTEGRATION NETWORK
Shiny + Plotly (~100 total lines of R code)
24
USE CASES – MARKET RESEARCH COMPANY
Shiny + Plotly
~340 lines of code
25
MORE ADVANCED USE CASE – BIOTECH COMPANY
Required custom d3.js within Shiny in order to build b-
directional interactive tree
CONSIDERATIONS
 Some data visualization efforts require more
customization than Plotly charts via R can provide.
– In these cases we still leverage Plotly charts where possible
but will write custom d3.js or other Javascript to accomplish
what we need.
 Use the right tool for the job
26
BENEFITS OF USING PLOTLY IN R
 Keep the analysis AND presentation layer in R as well
as publish results to web
 Efficiency (less coding = less time spent)
 Empowers data scientists to build beautiful interactive
dashboards
 Prototype potential solutions faster
 Confidence when pitching new prospects or bidding on
projects
27
THANK YOU
28
Brophy Analytics
www.brophyanalytics.com

SportsDataViz using Plotly, Shiny and Flexdashboard - PlotCon 2016

Editor's Notes

  • #25 http://ec2-54-226-208-55.compute-1.amazonaws.com:8080/IANS/