Introduction

This book is currently under development. It will be published in 2020 in the R Series by Chapman & Hall.

Motivation

This book will not get you started with Shiny, nor talk how to work with Shiny once it is sent to production. What we’ll see is the process of building an application that will later be sent to production. Why this topic? Lots of blog posts and books talk about getting started with {shiny} (Chang et al. 2020) or about what to do once your application is ready to be sent to production. Very few (if any) talk about this area in-between: how to confidently work with Shiny once you know the basics and before you send it to the production environment.

So this is what this book is going to talk about: building robust Shiny applications. We’ll focus on the process, the workflow, and the necessary tools for building production-grade Shiny Applications.

Who is this book for

If you are starting to read this book, we assume you have a working knowledge of how to build a small application using {shiny}, and want to know how to go one step further. In other words, you already have some knowledge about how {shiny} works, are able to build a small working application, and want to know how to build a serious, production-grade application that can be sent to production.

Book structure

  • Part 1 (Building Successful Shiny Apps) gives a general context about what we mean by “production-grade” and “successful” Shiny Application, and what challenges arise when you are dealing with a large scale application designed for production. In this part, we will define what we mean by “Successful”, stress the importance of project management, develop how to structure your project for production, and introduce the {golem} (Guyader et al. 2020) package We will finally briefly introduce to our development workflow: a workflow that will be explored in part 2 to 6.

  • Part 2 to 6 explore the workflow for building successful applications.
    Step 1: Design underlines the centrality of the user experience when engineering an application, emphasizes the importance of designing before coding, and gently introduces to CSS.
    Step 2: Prototype stresses the importance of prototyping, explores the setting of a {golem} based application, and presents {shinipsum}, {fakir}, and the “Rmd First” development methodology.
    Step 3: Build explores the building step of the application, i.e the core engineering of the application once the prototyping phase is finished.
    Step 4: Strengthen explores in depth testing, continuous integration, and version control.
    Step 5: Deploy develops the various possibilities for preparing your application to be deployed.

  • Part 7 (Optimizing) tackles the question of optimization, first by introducing the general concepts about optimization, then by presenting some common caveats of Shiny Apps, and then showing how to optimize R code, and how to use JavaScript to lighten R work.

About the authors

  • Colin Fay
  • Colin FAY works at ThinkR, a french agency focused on everything R-related.

    During the day, he helps companies to take full advantage of the power of R, by building tools (packages, web apps…) and setting up infrastructure. His main areas of expertise are data & software engineering, web applications (front-end and back-end), and R in production.

    During the night, Colin is also an hyperactive open source developer and an open data advocate. You can find a lot of his work on his GitHub account (https://github.com/ColinFay) and on ThinkR’s account (https://github.com/thinkr-open).

    He is also active in the Data Science community in France, especially in his home town Rennes, where he co-founded the Breizh Data Club association, and organizes the Breizh Data Club Meetups.

  • Sébastien Rochette
  • Sébastien is a data scientist at ThinkR, where he teaches anything R related from beginner to expert level, guides R developers towards implementation of best practices, and creates tailor-made R solutions for the needs of his customers.

  • Vincent Guyader
  • ThinkR Founder, with more than 10 years of experience, and with a scientific and technical background, Vincent is an R-enthusiast. He still has his hands in the code, whether to develop applications, analyze data or build packages. When he’s not coding, he plays with Docker and manages servers. He strongly believes that meeting highly technical challenges is not incompatible with pedagogy: he passionately trains very diverse learner profiles at R.

  • Cervan Girard
  • Cervan is Data Scientist at ThinkR. He is enthusiastic and motivated when it comes to rolling up his sleeves for new challenges, even if it means venturing dangerously into the depths of R, learning new languages and experimenting outside your comfort zone. Whatever the challenge, he remains reliable, constructive and efficient when it comes to using his skills to train or develop. He also enjoys training learners of all levels in the R language.

    Want to help?

    Any feedback on the book is very welcome. Feel free to open an issue, or to make a PR if you spot a typo.

    Other resources

    One single book could not cover everything there is to know about {shiny}. Here are some resources you can use in addition to this book. You can also find more resources in the bibliography.

    Disclaimer

    Open source is moving (very) fast, and some of the tools described in this book are still under active development. But good news! A large portion of this book is about the methodology, and not purely the technology, so even if some of the packages and code sections used in this book can become obsolete, a significant part of what is described in this book will still be relevant.

    When reading this book, remember that they are a “snapshot” of various technologies and packages, which might some day become out of date, have breaking changes, or even disappear. We will try to update the online version whenever changes are made to the packages used in this book, so feel free to browse the online version for the up-to-date information.

    The current version of this book has been compiled on:

    Sys.Date()
    [1] "2020-05-12"

    With the following configuration:

    See Session Information

    xfun::session_info()
    R version 3.6.3 (2020-02-29)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Ubuntu 18.04.4 LTS
    
    Locale:
      LC_CTYPE=C.UTF-8       LC_NUMERIC=C          
      LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8    
      LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
      LC_PAPER=C.UTF-8       LC_NAME=C             
      LC_ADDRESS=C           LC_TELEPHONE=C        
      LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
    
    Package version:
      askpass_1.1       assertthat_0.2.1 
      attempt_0.3.1     backports_1.1.6  
      base64enc_0.1.3   BH_1.72.0.3      
      bookdown_0.18     brew_1.0.6       
      callr_3.4.3       cli_2.0.2        
      clipr_0.7.0       codetools_0.2-16 
      commonmark_1.7    compiler_3.6.3   
      config_0.3        crayon_1.3.4     
      curl_4.3          desc_1.2.0       
      digest_0.6.25     dockerfiler_0.1.3
      ellipsis_0.3.0    evaluate_0.14    
      fansi_0.4.1       fastmap_1.0.1    
      fs_1.4.1          gh_1.1.0         
      git2r_0.27.1      glue_1.4.0       
      golem_0.2.1.9010  graphics_3.6.3   
      grDevices_3.6.3   here_0.1         
      highr_0.8         htmltools_0.4.0  
      httpuv_1.5.2      httr_1.4.1       
      ini_0.3.1         jsonlite_1.6.1   
      knitr_1.28        later_1.0.0.9004 
      lifecycle_0.2.0   magrittr_1.5     
      markdown_1.1      methods_3.6.3    
      mime_0.9          openssl_1.4.1    
      pillar_1.4.4      pkgbuild_1.0.8   
      pkgconfig_2.0.3   pkgload_1.0.2    
      praise_1.0.0      prettyunits_1.1.1
      processx_3.4.2    promises_1.1.0   
      ps_1.3.3          purrr_0.3.4      
      R6_2.4.1          Rcpp_1.0.4.6     
      rematch2_2.1.2    remotes_2.1.1    
      rlang_0.4.6       rmarkdown_2.1    
      roxygen2_7.1.0    rprojroot_1.3-2  
      rstudioapi_0.11   shiny_1.4.0.2    
      sourcetools_0.1.7 stats_3.6.3      
      stringi_1.4.6     stringr_1.4.0    
      sys_3.3           testthat_2.3.2   
      tibble_3.0.1      tinytex_0.22     
      tools_3.6.3       usethis_1.6.1    
      utf8_1.1.4        utils_3.6.3      
      vctrs_0.3.0       whisker_0.4      
      withr_2.2.0       xfun_0.13        
      xml2_1.3.2        xtable_1.8-4     
      yaml_2.2.1       

    Software information and conventions

    This book has been built with {knitr} (Xie 2020b) and {bookdown} (Xie 2020a).

    Package names are in curly brackets in code format (e.g., {rmarkdown}), and inline code and filenames are formatted in a typewriter font (e.g., knitr::knit('foo.Rmd')). Function names are formatted in a typewriter font and followed by parentheses (e.g., bookdown::render_book()).

    Acknowledgments

    Contributors to this book

    Thanks to them for their help on the book!

    References

    Chang, Winston, Joe Cheng, JJ Allaire, Yihui Xie, and Jonathan McPherson. 2020. Shiny: Web Application Framework for R. https://CRAN.R-project.org/package=shiny.

    Guyader, Vincent, Colin Fay, Sébastien Rochette, and Cervan Girard. 2020. Golem: A Framework for Robust Shiny Applications. https://github.com/ThinkR-open/golem.

    Xie, Yihui. 2020a. Bookdown: Authoring Books and Technical Documents with R Markdown. https://CRAN.R-project.org/package=bookdown.

    Xie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in R. https://CRAN.R-project.org/package=knitr.


    ThinkR Website