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
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8 (4 Ratings)
Paperback Sep 2018 238 pages 3rd Edition
eBook
₱1113.99 ₱1591.99
Paperback
₱1989.99
Subscription
Free Trial
Arrow left icon
Profile Icon Chris Beeley Profile Icon Shitalkumar R. Sukhdeve
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8 (4 Ratings)
Paperback Sep 2018 238 pages 3rd Edition
eBook
₱1113.99 ₱1591.99
Paperback
₱1989.99
Subscription
Free Trial
eBook
₱1113.99 ₱1591.99
Paperback
₱1989.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781788993128
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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 ₱260 each
Feature tick icon Exclusive print discounts
$279.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 ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 5,562.97
Web Application Development with R Using Shiny
₱1989.99
Data Analysis with R, Second Edition
₱2245.99
Hands-On Dashboard Development with Shiny
₱1326.99
Total 5,562.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.