Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Web Application Development with R Using Shiny
Web Application Development with R Using Shiny

Web Application Development with R Using Shiny: Build stunning graphics and interactive data visualizations to deliver cutting-edge analytics , Third Edition

Arrow left icon
Profile Icon Chris Beeley Profile Icon Shitalkumar R. Sukhdeve
Arrow right icon
€15.99 €23.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8 (4 Ratings)
eBook Sep 2018 238 pages 3rd Edition
eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Chris Beeley Profile Icon Shitalkumar R. Sukhdeve
Arrow right icon
€15.99 €23.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8 (4 Ratings)
eBook Sep 2018 238 pages 3rd Edition
eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Web Application Development with R Using Shiny

Shiny First Steps

In the previous chapter, we looked at R, learned some of its basic syntax, and saw some examples of the power and flexibility that R and Shiny offer. This chapter introduces the basics of Shiny. In this chapter, we're going to build our own application to interactively explore the Gapminder data described in the previous chapter. We will cover the following topics:

  • The types of Shiny application—R Markdown, single-file, two-file, Shiny gadgets
  • Interactive Shiny documents in R Markdown
  • Single-file Shiny applications
  • Two-file Shiny applications
  • A minimal example of a full Shiny application
  • Widget types
  • The basic structure of a Shiny program
  • The selection of simple input widgets (checkboxes and combo buttons)
  • The selection of simple output types (rendering plots and maps, and returning text)
  • The selection of simple layout types (page with sidebar and...

Types of Shiny application

In the first edition of this book, which was based on Shiny 0.6, we described only two types of application. First, a fairly simple Bootstrap-themed interface with input widgets down the left and output (a single page or a tabbed output window) on the right. The second type consisted of custom-built web pages with their own HTML and CSS files. Shiny has developed quite a bit since then, and there are actually many types of Shiny application and many ways of building them. These are as follows:

  • Interactive markdown documents with Shiny widgets embedded
  • Shiny applications (default CSS, written entirely in R)
  • Web pages (for example, custom CSS, HTML, and JavaScript)
  • Shiny gadgets
  • Flex dashboards

In this chapter, we will be considering the first two: interactive documents and full applications. Chapter 3, Integrating Shiny with HTML, will cover how to...

A minimal example of a full Shiny application

The first thing to note is that Shiny programs are the easiest to build and understand using two scripts, which are kept within the same folder. They should be named server.R and ui.R.

The ui.R of the minimal example

The ui.R file is a description of the UI, and is often the shortest and simplest part of a Shiny application. In the following code, note the use of the # character, which marks lines of code as comments that will not be run, but which are for the benefit of the humans producing the code:

fluidPage(                                 # Line 1 
  titlePanel("Minimal application"),       # Line 2 
  sidebarLayout(                           # Line 3 
    sidebarPanel...

Widget types

Before we move on to a more advanced application, let's have a look at the main widgets that you will make use of within Shiny. I've built a Shiny application that will show you what they all look like, as well as their outputs and the type of data they return. To run it, just enter the following command:

> library(shiny)
runGist(6571951)

This is one of the several built-in functions of Shiny that allow you to run code hosted on the internet. Details about sharing your own creations in other ways are discussed in Chapter 9, Persistence, Storage, and Sharing. The finished application looks like the following screenshot:

You can see the function names (checkboxGroupInput and checkboxInput) as numbered entries on the left-hand side of the panel; for more details, just type ?checkboxGroupInput into the console.

If you're curious about the code, it...

The Gapminder application

Now that we've got the basics, let's build a full application. Before we proceed, note that we will need to install a few packages—tidyverse, gapminder, leaflet, and ggmap. Each can be installed from CRAN (the official R package repository) using the code phrases install.packages("tidyverse"), install.packages("gapminder"), and so on. We will not install ggmap this way, though. At the time of writing, there is a bug in the CRAN version. We'll install the dev version instead, as shown in the following code:

install.packages("devtools")
library(devtools)
devtools::install_github("dkahle/ggmap")

The application is pretty simple to get us started, but it illustrates several important methods and principles in Shiny. It features tabbed output, which allows the user to select different inputs or groups...

Advanced layout features

In this chapter, we have covered the most simple of the layout features in Shiny with the help of the sidebarLayout(), mainPanel(), and tabsetPanel() functions. In later chapters, we will build larger and more complex applications, including dashboards, and make use of more advanced layout features. It is worth pausing here briefly to take a quick look at the other types of layout that are available so that you can think about the best way to implement your own application as we go through the next couple of chapters.

There are essentially two more broad types of layout function that you can use in Shiny. The first uses the layout features of Bootstrap and allows you to precisely define the layout of your application using a grid layout. Essentially, Bootstrap
asks you to define the UI as a series of rows. Each row can be further subdivided into columns...

Summary

In this chapter, we have covered a lot of ground. We've seen that Shiny applications are generally made up of two files: server.R and ui.R. You've learned what each part of the code does, including setting up ui.R with the position and type of inputs and outputs, and setting up server.R with the data processing functions, outputs, and any reactive objects that are required.

The optional exercises have given you a chance to experiment with the code files in this chapter, varying the output types, using different widgets, and reviewing and adjusting their return values as appropriate. You've learned about the default layout in Shiny, sidebarLayout(), as well as the use of mainPanel() and tabsetPanel().

You've also learned about reactive objects and when you might use them. There's more on finely controlling reactivity later in the book.

In the next...

Left arrow icon Right arrow icon

Key benefits

  • Explore the power of R Shiny to make interactive web applications easily
  • Create engaging user interfaces using elements such as HTML5 shiny tags and Ttabsets
  • Build and deploy your interactive Shiny web application using shinyapps.io

Description

Web Application Development with R Using Shiny helps you become familiar with the complete R Shiny package. The book starts with a quick overview of R and its fundamentals, followed by an exploration of the fundamentals of Shiny and some of the things that it can help you do. You’ll learn about the wide range of widgets and functions within Shiny and how they fit together to make an attractive and easy to use application. Once you have understood the basics, you'll move on to studying more advanced UI features, including how to style apps in detail using the Bootstrap framework or and Shiny's inbuilt layout functions. You'll learn about enhancing Shiny with JavaScript, ranging from adding simple interactivity with JavaScript right through to using JavaScript to enhance the reactivity between your app and the UI. You'll learn more advanced Shiny features of Shiny, such as uploading and downloading data and reports, as well as how to interact with tables and link reactive outputs. Lastly, you'll learn how to deploy Shiny applications over the internet, as well as and how to handle storage and data persistence within Shiny applications, including the use of relational databases. By the end of this book, you'll be ready to create responsive, interactive web applications using the complete R (v 3.4) Shiny (1.1.0) suite.

Who is this book for?

Web Application Development with R Using Shiny is for you if you are interested in creating compelling web applications and interactive data visualization over the web using Shiny. Programming experience with R is required.

What you will learn

  • Harness the power of JavaScript to customize your applications
  • Build dashboards with predefined UI and layouts
  • Engage your users and build better analytics using interactive plots
  • Learn advanced code patterns to make your applications easy to write and maintain.
  • Develop a full understanding of Shiny s UI functions to give you the power to build a wide variety of attractive applications.
  • Store data and interact with databases with Shiny.
  • Learn how to share your Shiny applications
  • Understand reactivity at the conceptual level to build more efficient and robust apps

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 27, 2018
Length: 238 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788998284
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Sep 27, 2018
Length: 238 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788998284
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 82.97
Web Application Development with R Using Shiny
€29.99
Data Analysis with R, Second Edition
€32.99
Hands-On Dashboard Development with Shiny
€19.99
Total 82.97 Stars icon

Table of Contents

10 Chapters
Beginning R and Shiny Chevron down icon Chevron up icon
Shiny First Steps Chevron down icon Chevron up icon
Integrating Shiny with HTML Chevron down icon Chevron up icon
Mastering Shiny's UI Functions Chevron down icon Chevron up icon
Easy JavaScript and Custom JavaScript Functions Chevron down icon Chevron up icon
Dashboards Chevron down icon Chevron up icon
Power Shiny Chevron down icon Chevron up icon
Code Patterns in Shiny Applications Chevron down icon Chevron up icon
Persistent Storage and Sharing Shiny Applications Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8
(4 Ratings)
5 star 50%
4 star 0%
3 star 25%
2 star 25%
1 star 0%
TD Sep 05, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Das Buch ist als Vertiefung sehr gut geeignet. Gute Kenntnisse von R sollten bereits vorhanden sein. Hervorragend sind die gut strukturierten und erklärten Beispiele. Die Druckqualität der Screenshots könnte besser sein.
Amazon Verified review Amazon
alba1988 Apr 24, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Muy interesantes para trabajar con fata cience
Amazon Verified review Amazon
Eli Jul 18, 2021
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Very very basic. They should have added for beginners in R
Amazon Verified review Amazon
Deep Breath - Fast Run May 30, 2019
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Not overlapping for quite some portions with the first edition, the book covers information about R/Shiny that seems to be not very practical nor essential. I have basic knowledge on R/Shiny, can write basic apps. This book adds little to my skill. The description of R/Shiny are very limited, a broad range of practical techniques for app constructions are not mentioned.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.