RStudio Conference
San Francisco
2020-01-29

Interactive Graphics

Full Interactivity

  • Requires statistical software to be run, i.e., report not self-contained and useable offline. Think RShiny
  • E.g. change the bandwidth and re-run a nonparametric smoother for trend; selection of variables to include in a model

Partial interactivity

  • Zoom, pan
  • Rescale axes
  • Extra information pop-up (hover text)
  • Select which traces to show
  • Instead of having legends and explanations (e.g., for box plots) show extra information as hover text

R Software: plotly Package

  • Implementation of javascript D3 graphics model plotly
  • Best developed partially interactive scientific graphics for R
  • Has it’s own model, or:
  • ggplotly function: pass any ggplot2 graphics object through it to get interactivity

New plotly Graphics Functions in Hmisc and rms Packages

  • html methods for describe, summaryM
  • histboxp
  • survplotp
  • Advanced HTML tables using htmlTable

Clinical Trial Reports

High-Level Abstractions

  • Foster good statistical analysis, graphics, reporting practice
  • Minimize programming for individual clinical trials
  • Reviewers are tired of tables and reports having 100s of pages
  • Clinical trial reports have many standard components

Some Standard RCT Report Components

  • accrual summary
  • patient flow/exclusions
  • baseline description
  • longitudinal analyses
  • adverse events
  • lab safety parameters (blood, ekg, etc.)
  • event timing/incidence
  • sequential monitoring of event probabilities

RCT Report Philosophy

  • Tables do not lead to pattern recognition
  • Graphics > tables when >2 numbers in the table
  • Graphics should use features humans most accurately perceive
    • position along a common scale
  • Need for signposts on graphics
  • Tables are secondary; should be in appendix and hyperlinked
    • or as hovertext from a plot

Philosophy, continued

  • Emphasize confidence intervals for differences
  • Show entire distributions when possible
  • Favor quantiles over moments
  • Percentages are inherently confusing
    • replace with proportions and ratios

R Packages greport (PDF) and hreport (HTML)

  • Utility functions
  • High-level report component functions
  • Unified handling of figure generation, captions
  • New graphical elements

High-Level Functions

  • accrualReport: subject accrual, accounting for regions, countries, sites
  • exReport: exclusion and improper randomization report
  • dReport: descriptive stats for baseline and longitudinal data
  • eReport: event report
  • survReport: time-to-event report

High-Level Functions, continued

  • nriskReport: number–at–risk report (declining denominators for longitudinal data)
  • (future): sequential monitoring of event incidence/stopping boundaries
  • analysis variables ~ stratification vars + id(subject ID var)

New HTML Model: hreport Package

  • RMarkdown → html documents
    • html reports allow semi-interactive graphics
  • R functions write HTML
    • Regular tabular output, hyperlinks, navigation bars, etc.
  • Almost no tables
  • Hover over a graphical element to see the relevant portion of a table

hreport Example html Reports

For More Information

  • biostat.mc.vanderbilt.edu/RCTGraphics
  • github.com/harrelfe
  • fharrell.com