Learning Shiny

Book description

Make the most of R's dynamic capabilities and implement web applications with Shiny

About This Book

  • Present interactive data visualizations in R within the Shiny framework
  • Construct web dashboards in a simple, intuitive, but fully flexible environment
  • Apply your skills to create a real-world web application with this step-by-step guide

Who This Book Is For

If you are a data scientist who needs a platform to show your results to a broader audience in an attractive and visual way, or a web developer with no prior experience in R or Shiny, this is the book for you.

What You Will Learn

  • Comprehend many useful functions, such as lapply and apply, to process data in R
  • Write and structure different files to create a basic dashboard
  • Develop graphics in R using popular graphical libraries such as ggplot2 and GoogleVis
  • Mount a dashboard on a Linux Server
  • Integrate Shiny with non-R-native visualization, such as D3.js
  • Design and build a web application

In Detail

R is nowadays one of the most used tools in data science. However, along with Shiny, it is also gaining territory in the web application world, due to its simplicity and flexibility. Shiny is a framework that enables the creation of interactive visualizations written entirely in R and can be displayed in almost any ordinary web browser. It is a package from RStudio, which is an IDE for R.

From the fundamentals of R to the administration of multi-concurrent, fully customized web applications, this book explains how to achieve your desired web application in an easy and gradual way.

You will start by learning about the fundamentals of R, and will move on to looking at simple and practical examples. These examples will enable you to grasp many useful tools that will assist you in solving the usual problems that can be faced when developing data visualizations. You will then walk through the integration of Shiny with R in general and view the different visualization possibilities out there. Finally, you will put your skills to the test and create your first web application!

Style and approach

This is a comprehensive, step-by-step guide that will allow you to learn and make full use of R and Shiny's capabilities in a gradual way, together with clear, applied examples.

Table of contents

  1. Learning Shiny
    1. Table of Contents
    2. Learning Shiny
    3. Credits
    4. About the Author
    5. Acknowledgements
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    8. 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. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    9. 1. Introducing R, RStudio, and Shiny
      1. About R
        1. Installing R
        2. A quick guide to R
      2. About RStudio
        1. Installing RStudio
        2. A quick guide to RStudio
      3. About Shiny
        1. Installing and loading Shiny
      4. Summary
    10. 2. First Steps towards Programming in R
      1. Object-oriented programming concepts
      2. Variables in R
      3. Classes in depth
        1. Vectors
        2. Lists
        3. Matrices and arrays
        4. Data frames
        5. Factors
      4. Element selection
        1. Selecting elements from vectors
        2. Selecting elements from arrays
        3. Selecting elements from lists
        4. Selecting elements from data frames
      5. Control structures in R
        1. The if...else block
        2. The while loop
        3. The for loop
        4. The switch statement
      6. Reading data
        1. Delimited data
        2. Reading line by line
        3. Reading a character set
        4. Reading JSON
        5. Reading XML
        6. Reading databases – SQL
        7. Reading data from external sources
      7. Summary
    11. 3. An Introduction to Data Processing in R
      1. Sorting elements
        1. sort() versus order()
      2. Basic summary functions
      3. grep and regular expressions
        1. A brief introduction to regular expressions
          1. Sets
            1. Shortcuts
            2. Dot
          2. Non-printable characters
          3. Negation
          4. Alternation
          5. Quantifiers
            1. Special quantifiers
          6. Anchors
          7. Expressions
          8. Escapes
        2. Examples
          1. Example 1
          2. Example 2
      4. The lapply, vapply, sapply, and apply functions
        1. Examples
      5. plyr
      6. The data.table package
      7. reshape2
      8. Summary
    12. 4. Shiny Structure – Reactivity Concepts
      1. Shiny as a package
      2. An introduction to server.R and UI.R
        1. UI.R as a JavaScript/HTML wrapper
        2. Including HTML within UI.R
      3. The concept of reactivity
      4. Reactive independent processes within an application
      5. An introduction to global.R
      6. Running a Shiny web application
      7. An overview of simple examples
        1. Example 1 – a general example of how render-like functions work
        2. Example 2 – using reactive objects
        3. Example 3 – Loading data outside reactive context
        4. Example 4 – using global.R
      8. Summary
    13. 5. Shiny in Depth – A Deep Dive into Shiny's World
      1. UI.R
        1. The structure
          1. conditionalPanel() – Example 1
          2. conditionalPanel() – Example 2
          3. An example on the use of tabPanel() in tabsetPanel()
        2. Inputs
          1. Free inputs
          2. Lists
          3. Dates
          4. Files
          5. Buttons
            1. submitButton() with conditionalPanel()
          6. downloadButton() - an example
      2. Optimal usage of server.R and global.R
      3. Shiny options
      4. Summary
    14. 6. Using R's Visualization Alternatives in Shiny
      1. The graphics package
        1. Barplot
        2. Histograms
        3. Boxplots
        4. Pie charts
        5. Points
        6. Lines
      2. Plotting options
      3. Legends
      4. Plotting a fully customized plot with the graphics package
      5. Including a plot in a Shiny application
      6. A walk around the googleVis package
        1. googleVis in R
        2. An overview of some functions
          1. Candlesticks
          2. Geolocalized visualizations
          3. Treemaps
          4. Motion chart
        3. googleVis in Shiny
          1. A small example of googleVis in Shiny
      7. ggplot2 – first steps
        1. ggplot's main logic – layers and aesthetics
          1. Layers
          2. Aesthetics
        2. Some graphical tools in ggplot2
          1. geom_point
          2. geom_line
          3. geom_bars
        3. An applied example with multiple layers
        4. ggplot and Shiny
      8. Summary
    15. 7. Advanced Functions in Shiny
      1. The validate() function
      2. The isolate() function
      3. The observe() function
      4. The reactiveValues() function
      5. Input updates
      6. Summary
    16. 8. Shiny and HTML/JavaScript
      1. The www directory
      2. Creating UIs from plain HTML
      3. The use of tags in UI.R
        1. JavaScript
        2. CSS
        3. Other tags
      4. Relating HTML/JavaScript and server.R
      5. Summary
    17. 9. Interactive Graphics in Shiny
      1. Interaction possibilities within R graphics
      2. D3.js integration
        1. What is D3?
        2. networkD3
        3. An introduction to htmlwidgets
          1. D3BarChart.R
          2. D3BarChart.js
          3. D3BarChart.yaml
      3. Summary
    18. 10. Sharing Applications
      1. runGist/runGitHub/runUrl
      2. shinyapps.io
        1. Deploying applications on your own server
        2. Installing R
        3. Installing the RStudio server
        4. Installing the Shiny package
          1. run_as
          2. listen
          3. location
          4. site_dir/app_dir
          5. directory_index
      3. Summary
    19. 11. From White Paper to a Full Application
      1. Problem presentation
      2. Conceptual design
      3. Pre-application processing
        1. Workclass
      4. global.R coding
        1. global.R
      5. UI.R partial coding
        1. UI.R
      6. server.R coding
        1. Gender bar chart
        2. Age chart
        3. Ethnic bar chart
        4. Marital status
        5. Education curve
        6. Earnings chi-square test
        7. Activity summary
      7. UI.R completion
        1. UI.R
      8. Styling
        1. Discovering insights in the application
      9. Summary
      10. Reference
    20. Index

Product information

  • Title: Learning Shiny
  • Author(s): Hernán G. Resnizky
  • Release date: October 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781785280900