O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Web Application Development with R Using Shiny - Second Edition

Book Description

Integrate the power of R with the simplicity of Shiny to deliver cutting-edge analytics over the Web

About This Book

  • Use Shiny's built-in functions to produce engaging user interfaces, and integrate them into your own web pages

  • Implement powerful user-contributed packages to access graphics from the web, make your own dashboards, use interactive maps, and more

  • Extend Shiny using JavaScript and jQuery with minimal coding using this handy, step-by-step guide

  • Who This Book Is For

    This book is for anybody who wants to produce interactive data summaries over the web, whether you want to share them with a few colleagues or the whole world. No previous experience with R, Shiny, HTML, or CSS is required to begin using this book, although you should possess some previous experience with programming in a different language.

    What You Will Learn

  • Build interactive applications using Shiny's built-in widgets

  • Use the built-in layout functions in Shiny to produce user-friendly applications

  • Integrate Shiny applications with web pages and customize them using HTML and CSS

  • Harness the power of JavaScript and jQuery to customize your applications

  • Engage your users and build better analytics using interactive plots

  • Debug your applications using Shiny's built-in functions

  • Deliver simple and powerful analytics across your organization using Shiny dashboards

  • Share your applications with colleagues or over the Internet using cloud services or your own server

  • In Detail

    R is a highly flexible and powerful tool for analyzing and visualizing data. Most of the applications built using various libraries with R are desktop-based. But what if you want to go on the web? Here comes Shiny to your rescue!

    Shiny allows you to create interactive web applications using the excellent analytical and graphical capabilities of R. This book will guide you through basic data management and analysis with R through your first Shiny application, and then show you how to integrate Shiny applications with your own web pages. Finally, you will learn how to finely control the inputs and outputs of your application, along with using other packages to build state-of-the-art applications, including dashboards.

    Style and approach

    Learn by doing! Each chapter includes code and examples to use and adapt for your own applications. As the chapters progress, the code and examples are built upon until you have all the materials required to build a large, complex, real-world analytics application.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Web Application Development with R Using Shiny Second Edition
      1. Table of Contents
      2. Web Application Development with R Using Shiny Second Edition
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Getting Started with R and Shiny!
        1. Installing R
        2. The R console
        3. Code editors and IDEs
        4. Learning R
          1. Getting help
        5. Loading data
        6. Data types and structures
          1. Dataframes, lists, arrays, and matrices
          2. Variable types
          3. Functions
          4. Objects
        7. Base graphics and ggplot2
          1. Bar chart
          2. Line chart
        8. Advanced tasks with dplyr and ggvis
          1. Preparing the data
          2. A simple interactive line plot
        9. Installing Shiny and running the examples
        10. Summary
      9. 2. Building Your First Application
        1. Types of Shiny application
          1. Interactive Shiny documents in RMarkdown
        2. A minimal example of a fully Shiny application
          1. ui.R of minimal example
            1. A note on HTML helper functions
            2. The finished interface
          2. server.R of minimal example
            1. The program structure
            2. An optional exercise
              1. Embedding applications in documents
        3. Widget types
        4. The Google Analytics application
          1. The UI
          2. Data processing
          3. Reactive objects
          4. Outputs
            1. Text summary
            2. Trend graphs
            3. A map of users across the world
          5. A note on the application code
          6. An optional exercise
        5. Advanced layout features
        6. Summary
      10. 3. Building Your Own Web Pages with Shiny
        1. Running the applications and code
        2. Shiny and HTML
        3. Custom HTML links in Shiny
          1. ui.R
          2. server.R
            1. server.R – data preparation
            2. server.R – the server definition
        4. A minimal HTML interface
          1. index.html
          2. server.R
        5. JavaScript and Shiny
          1. Example 1 – reading and writing the DOM
            1. ui.R
            2. server.R
          2. Example 2 – sending messages between client and server
            1. ui.R
            2. server.R
            3. dropdownDepend.js
          3. Take a step back and rewind
        6. jQuery
          1. index.html – the body
          2. server.R
        7. Exercise
          1. Debugging
        8. Bootstrap 3 and Shiny
        9. Summary
      11. 4. Taking Control of Reactivity, Inputs, and Outputs
        1. What's new in our application?
        2. Downloading data from RGoogleAnalytics
        3. Animation
        4. Streamline the UI by hiding elements
        5. Naming tabPanel elements
        6. Beautiful tables with DataTable
        7. Reactive user interfaces
          1. The reactive user interface example – server.R
          2. The reactive user interface example – ui.R
        8. Progress bars
        9. Advanced reactivity and data handling
          1. Controlling the whole interface with submitButton()
          2. Controlling specific inputs with the isolate() function
          3. Running reactive functions over time
          4. Using reactive objects and functions efficiently
        10. More advanced topics in Shiny
          1. Finely controlling inputs and outputs
          2. Reading client information and GET requests in Shiny
          3. Custom interfaces from GET strings
        11. Advanced graphics options
        12. Downloading graphics and reports
        13. Downloadable reports with knitr
        14. Downloading and uploading data
        15. Debugging
          1. Good practice when coding Shiny applications
          2. Debugging functions
        16. Summary
      12. 5. Advanced Applications I – Dashboards
        1. Applications in this chapter
        2. Version one – sidebar layout
        3. Adding icons to your UI
        4. Using shinyBS to add pop-ups and tooltips
          1. ui.R
        5. Adding a pop-up window to an output
        6. Using shinythemes
        7. Version two – grid layout (A)
          1. ui.R
        8. Version two – grid layout (B)
          1. ui.R
        9. Version three – navigation bar
          1. ui.R
        10. Version four – dashboard
        11. Notifications
        12. Info boxes
          1. ui.R
        13. Google Charts gauge
        14. Resizing the google chart
          1. ui.R
        15. Summary
      13. 6. Advanced Applications II – Using JavaScript Libraries in Shiny Applications
        1. The htmlwidgets package
        2. The application framework
          1. ui.R
        3. Dygraphs
          1. server.R
        4. Dygraphs with a prediction
        5. rCharts
        6. d3heatmap
        7. threejs
        8. Summary
      14. 7. Sharing Your Creations
        1. Sharing with the R community
          1. Sharing over GitHub
          2. An introduction to Git
        2. Using Git and GitHub within Rstudio
          1. Projects in RStudio
          2. Sharing applications using Git
          3. Sharing using .zip and .tar
            1. Sharing with the world
          4. Shinyapps.io
            1. Shinyapps.io without RStudio
            2. Shiny Server
          5. Scoping, loading, and reusing data in Shiny applications
            1. Temporary data input/output
            2. Permanent data functions
          6. Browser compatibility
        3. Summary
      15. Index