1 Building Statistical Data Science Software:
R Packages and Visualization

1.1 Course overview

This course provides an overview of the statistical software R (https://www.r-project.org) and describes several R packages to create static and interactive visualizations, build R packages, create websites, and to easily turn analyses into visually informative and interactive reproducible reports, dashboards, and Shiny web applications that facilitate reproducible research and the communication of insights to collaborators and policymakers.

Objectives: After taking this course, students should be able to use R to create the following:

  • Static and interactive data visualizations
  • Reproducible documents with R Markdown
  • Interactive dashboards and Shiny web applications
  • R packages following best practices for software development
  • Websites with the blogdown package
  • GitHub repositories with R projects to collaborate and websites to share content with others

1.2 Course schedule

Week 1: Introduction to R and RStudio (data types, data manipulation, analysis and visualization)

  • Intro R
  • Intro R 2

Week 2: R packages for visualization: static visualizations with ggplot2 (including time series and maps)

Week 3: R packages for visualization: interactive visualizations with plotly, gganimate and HTML widgets

Week 3-1 plotly and gganimate:

library(plotly)
p <- ggplot() + geom_*()
ggplotly(p)
library(gganimate)
p <- ggplot() + geom_*() + transition_*()
p
# If plot does not render automatically, use animate()
library(gifski)
animate(p, renderer = gifski_renderer()) # produces gif

Week 3-2 HTML widgets:

Week 4: Reproducible reports with R Markdown. Dashboards with flexdashboard. GitHub (creating R projects and hosting websites)

Week 5: Shiny web applications: user interface, server function, inputs, outputs, layout
Week 6: Shiny web applications: reactive expressions. Sharing Shiny apps. Interactive dashboards with flexdashboard and Shiny
Week 7: Break. Shiny web applications: spatial example

  • Shiny

Week 8: Presentations

Week 9: Creating websites with several R Markdown documents. Creating presentations with R Markdown

  • RM websites
  • RM presentations

Week 10: R packages for accessing and visualizing open spatial data

Week 11: Presentations

Week 12: Building R Packages: organizing, documenting and testing code
Week 13: Building R Packages: software review and best practices. Websites for packages. Hexstickers

  • R packages

Week 14: Authoring books and technical documents with bookdown. Creating websites with blogdown

  • bookdown
  • blogdown

Week 15: Presentations

1.3 References

  • https://rstudio.com/resources/books/
  • Hadley Wickham and Garrett Grolemund. R for Data Science. O’Reilly.
  • Yihui Xie, JJ Allaire, and Garrett Grolemund. R Markdown: The Definitive Guide. The R Series.
    https://bookdown.org/yihui/rmarkdown/
  • Hadley Wickham. R Packages: Organize, Test, Document, and Share Your Code. O’Reilly.
  • Yihui Xie, Amber Thomas, Alison Hill. blogdown: Creating Websites with R Markdown. The R Series.
  • Yihui Xie. bookdown: Authoring Books and Technical Documents with R Markdown. The R Series.
  • Hadley Wickham. Mastering Shiny: Build interactive apps, reports & dashboards powered by R. O’Reilly.
    https://mastering-shiny.org/
  • Paula Moraga. Geospatial Health Data: Modeling and Visualization with R-INLA and Shiny. CRC Press.
    https://www.paulamoraga.com/book-geospatial

1.4 License

You may not copy or distribute the course materials.