Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learning Shiny
Learning Shiny

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

Arrow left icon
Profile Icon Hernan Resnizky
Arrow right icon
Free Trial
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9 (7 Ratings)
Paperback Oct 2015 246 pages 1st Edition
eBook
S$12.99 S$47.99
Paperback
S$59.99
Subscription
Free Trial
Arrow left icon
Profile Icon Hernan Resnizky
Arrow right icon
Free Trial
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9 (7 Ratings)
Paperback Oct 2015 246 pages 1st Edition
eBook
S$12.99 S$47.99
Paperback
S$59.99
Subscription
Free Trial
eBook
S$12.99 S$47.99
Paperback
S$59.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

Learning Shiny

Chapter 1. Introducing R, RStudio, and Shiny

In this chapter, the main objective will be to learn how to install all the needed components to build an application in R with Shiny. Additionally, some general ideas about what R is will be covered in order to be able to dive deeper into programming using R.

The following topics will be covered in this chapter:

  • A brief introduction to R, RStudio, and Shiny
  • Installation of R and Shiny
  • General tips and tricks

About R

As stated on the R-project main website:

"R is a language and environment for statistical computing and graphics."

R is a successor of S and is a GNU project. This means, briefly, that anyone can have access to its source codes and can modify or adapt it to their needs. Nowadays, it is gaining territory over classic commercial software, and it is, along with Python, the most used language for statistics and data science.

Regarding R's main characteristics, the following can be considered:

  • Object oriented: R is a language that is composed mainly of objects and functions. Chapter 2, First Steps towards Programming in R, and Chapter 3, An Introduction to Data Processing in R, will cover object and function handling in R.
  • Can be easily contributed to: Similar to GNU projects, R is constantly being enriched by users' contributions either by making their codes accessible via "packages" or libraries, or by editing/improving its source code. There are actually almost 7000 packages in the common R repository, Comprehensive R Archive Network (CRAN). Additionally, there are other R repositories of public access, such as the bioconductor project which contains packages for bioinformatics.
  • Runtime execution: Unlike C or Java, R does not need compilation. This means that you can, for instance, write 2 + 2 in the console and it will return the value.
  • Extensibility: The R functionalities can be extended through the installation of packages and libraries. Standard proven libraries can be found in CRAN repositories and are accessible directly from R by typing install.packages().

Installing R

R can be installed in every operating system. It is highly recommended to download the program directly from http://cran.rstudio.com/ when working on Windows or Mac OS. On Ubuntu, R can be easily installed from the terminal as follows:

sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev

The installation of r-base-dev is highly recommended as it is a package that enables users to compile the R packages from source, that is, maintain the packages or install additional R packages directly from the R console using the install.packages() command.

To install R on other UNIX-based operating systems, visit the following links:

A quick guide to R

When working on Windows, R can be launched via its application. After the installation, it is available as any other program on Windows. When opening the program, a window like this will appear:

A quick guide to R

When working on Linux, you can access the R console directly by typing R on the command line:

A quick guide to R

In both the cases, R executes in runtime. This means that you can type in code, press Enter, and the result will be given immediately as follows:

> 2+2
[1] 4

The R application in any operating system does not provide an easy environment to develop code. For this reason, it is highly recommended (not only to write web applications in R with Shiny, but for any task you want to perform in R) to use an Integrated Development Environment (IDE).

The topics related to the R language are covered mainly in Chapter 2, First Steps towards Programming in R, and Chapter 3, An Introduction to Data Processing in R.

About RStudio

As with other programming languages, there is a huge variety of IDEs available for R. IDEs are applications that make code development easier and clearer for the programmer. RStudio is one of the most important ones for R, and it is especially recommended to write web applications in R with Shiny because this contains features specially designed for this purpose. Additionally, RStudio provides facilities to write C++, Latex, or HTML documents and also integrates them to the R code.

RStudio also provides version control, project management, and debugging features among many others.

Installing RStudio

RStudio for desktop computers can be downloaded from its official website at http://www.rstudio.com/products/rstudio/download/ where you can get versions of the software for Windows, MAC OS X, Ubuntu, Debian, and Fedora.

A quick guide to RStudio

Before installing and running RStudio, it is important to have R installed. As it is an IDE and not the programming language, it will not work at all. The following screenshot shows RStudio's starting view:

A quick guide to RStudio

At the first glance, the following four main windows are available:

  • Text editor: This provides facilities to write R scripts such as highlighting and a code completer (when hitting Tab, you can see the available options to complete the code written). It is also possible to include R code in an HTML, Latex, or C++ piece of code.
  • Environment and history: They are defined as follows:
    • In the Environment section, you can see the active objects in each environment. By clicking on Global Environment (which is the environment shown by default), you can change the environment and see the active objects. You can find more information about environments in a chapter dedicated to this topic in the book Advanced R, by Hadley Wickham. It is available at http://adv-r.had.co.nz/Environments.html.
    • In the History tab, the pieces of codes executed are stored line by line. You can select one or more lines and send them either to the editor or to the console. In addition, you can look up for a certain specific piece of code by typing it in the textbox in the top right part of this window.
  • Console: This is an exact equivalent of R console, as described in Quick guide of R.
  • Tabs: The different tabs are defined as follows:
    • Files: This consists of a file browser with several additional features (renaming, deleting, and copying). Clicking on a file will open it in editor or the Environment tab depending on the type of the file. If it is a .rda or .RData file, it will open in both. If it is a text file, it will open in one of them.
    • Plots: Whenever a plot is executed, it will be displayed in that tab.
    • Packages: This shows a list of available and active packages. When the package is active, it will appear as clicked. Packages can also be installed interactively by clicking on Install Packages.
    • Help: This is a window to seek and read active packages' documentation.
    • Viewer: This enables us to see the HTML-generated content within RStudio.

Along with numerous features, RStudio also provides keyboard shortcuts. A few of them are listed as follows:

Description

Windows/Linux

OSX

Complete the code.

Tab

Tab

Run the selected piece of code. If no piece of code is selected, the active line is run.

Ctrl + Enter

⌘ + Enter

Comment the selected block of code.

Ctrl + Shift + C

⌘ + /

Create a section of code, which can be expanded or compressed by clicking on the arrow to the left. Additionally, it can be accessed by clicking on it in the bottom left menu.

#####

#####

Find and replace.

Ctrl + F

⌘ + F

The following screenshots show how a block of code can be collapsed by clicking on the arrow and how it can be accessed quickly by clicking on its name in the bottom-left part of the window:

A quick guide to RStudio

Clicking on the circled arrow will collapse the Section 1 block, as follows:

A quick guide to RStudio

The full list of shortcuts can be found at https://support.rstudio.com/hc/en-us/articles/200711853-Keyboard-Shortcuts.

Note

For further information about other RStudio features, the full documentation is available at https://support.rstudio.com/hc/en-us/categories/200035113-Documentation.

About Shiny

Shiny is a package created by RStudio, which enables to easily interface R with a web browser. As stated in its official documentation, Shiny is a web application framework for R that makes it incredibly easy to build interactive web applications with R.

One of its main advantages is that there is no need to combine R code with HTML/JavaScript code as the framework already contains prebuilt features that cover the most commonly used functionalities in a web interactive application. There is a wide range of software that has web application functionalities, especially oriented to interactive data visualization. What are the advantages of using R/Shiny then, you ask? They are as follows:

  • It is free not only in terms of money but (as with all GNU projects) in terms of freedom. As stated in the GNU main page: To understand the concept, you should think of "free" as in "free speech", not as in "free beer". Free software is a matter of the users' freedom to run, copy, distribute, study, change, and improve the software.
  • All the possibilities of a powerful language such as R is available. Thanks to its contributive essence, you can develop a web application that can display any R-generated output. This means that you can, for instance, run complex statistical models and return the output in a friendly way in the browser, obtain and integrate data from the various sources and formats (for instance, SQL, XML, JSON, and so on) the way you need, and subset, process, and dynamically aggregate the data the way you want. These options are not available (or are much more difficult to accomplish) under most of the commercial BI tools.

Installing and loading Shiny

As with any other package available in the CRAN repositories, the easiest way to install Shiny is by executing install.packages("shiny").

The following output should appear on the console:

Installing and loading Shiny

Due to R's extensibility, many of its packages use elements (mostly functions) from other packages. For this reason, these packages are loaded or installed when the package that is dependent on them is loaded or installed. This is called dependency. Shiny (on its 0.10.2.1 version) depends on Rcpp, httpuv, mime, htmltools, and R6.

An R session is started only with the minimal packages loaded. So if functions from other packages are used, they need to be loaded before using them. The corresponding command for this is as follows:

library(shiny)

When installing a package, the package name must be quoted but when loading the package, it must be unquoted.

Summary

After these instructions, the reader should be able to install all the fundamental elements to create a web application with Shiny. Additionally, he or she should have acquired at least a general idea of what R and the R project is.

The next chapter will focus on the first steps of programming in R and the key elements of this language.

Left arrow icon Right arrow icon

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.

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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 16, 2015
Length: 246 pages
Edition : 1st
Language : English
ISBN-13 : 9781785280900
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 : Oct 16, 2015
Length: 246 pages
Edition : 1st
Language : English
ISBN-13 : 9781785280900
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 S$6 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 S$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total S$ 194.97
Mastering RStudio: Develop, Communicate, and Collaborate with R
S$74.99
Learning Shiny
S$59.99
Web Application Development with R Using Shiny Second Edition
S$59.99
Total S$ 194.97 Stars icon
Banner background image

Table of Contents

12 Chapters
1. Introducing R, RStudio, and Shiny Chevron down icon Chevron up icon
2. First Steps towards Programming in R Chevron down icon Chevron up icon
3. An Introduction to Data Processing in R Chevron down icon Chevron up icon
4. Shiny Structure – Reactivity Concepts Chevron down icon Chevron up icon
5. Shiny in Depth – A Deep Dive into Shiny's World Chevron down icon Chevron up icon
6. Using R's Visualization Alternatives in Shiny Chevron down icon Chevron up icon
7. Advanced Functions in Shiny Chevron down icon Chevron up icon
8. Shiny and HTML/JavaScript Chevron down icon Chevron up icon
9. Interactive Graphics in Shiny Chevron down icon Chevron up icon
10. Sharing Applications Chevron down icon Chevron up icon
11. From White Paper to a Full Application Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9
(7 Ratings)
5 star 28.6%
4 star 0%
3 star 28.6%
2 star 14.3%
1 star 28.6%
Filter icon Filter
Top Reviews

Filter reviews by




M. Rumore Jan 26, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I disagree with the other reviewers. This book is an introduction to Shiny and it covers the case where the reader may also be new to R.It provides an excellent description of the Shiny archictecture, the connection between the UI processing and the data-processing backend. The chapters slowly progress through the various Shiny capabilites with straightforward examples which are easy to understand and demonstrate the interactions between user-input, data processing, UI updates, etc. It also covers (briefly) how to include HTML, CSS, javascript into Shiny applications.The final chapter develops an application where all the parts are linked and demonstrated.If you need more details, then you do have to look elsewhere.
Amazon Verified review Amazon
Oscar Jun 11, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excelente libro
Amazon Verified review Amazon
Ray O Light Nov 30, 2015
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This is value for money given the technical content of the book.What I liked about the book is that it goes straight to giving the technical knowledge and understanding of Shiny.Where I would think it could be better is to bring the last chapter forward and start off with an overarching view of using Shiny and its Conceptual design (this would help the reader to associate better web design and using Shiny). Also suggest removing the introduction to R portion, which is too brief and not necessary since it is very likely people who wish to learn about Shiny already know R. (started reading straight from chapter 4).Overall, this book is geared more towards the technical aspect and helps to stir interest in picking up Shiny development.
Amazon Verified review Amazon
Amazon Customer Nov 19, 2015
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
There are very rare books written on shiny. It is an introductory book to get you started with Shiny. The book covers very basic examples so do n't expect to have expert skills after reading this book. Chapter 11 From White Paper to a Full Application did nice job in giving an overview of end to end development process.
Amazon Verified review Amazon
MR MW GREGORY Oct 10, 2016
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Online tutorials provided by R Studio are superior. Provides little additional value for the cost. Probably good if you are new to R and Shiny, not good for advanced users.
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.