Learning Shiny
eBook - ePub

Learning Shiny

  1. 246 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning Shiny

About this book

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.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Learning Shiny


Table of Contents

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

Learning Shiny

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2015
Production reference: 1141015
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-090-0
www.packtpub.com

Credits

Author
Hernán G. Resnizky
Reviewers
Dean Attali
William Kyle Hamilton
Achyutuni Sri Krishna Rao
Commissioning Editor
Kunal Parikh
Acquisition Editors
Shaon Basu
Larissa Pinto
Content Development Editor
Ritika Singh
Technical Editor
Shiny Poojary
Copy Editor
Kausambhi Majumdar
Project Coordinator
Judie Jose
Proofreader
Safis Editing
Indexer
Rekha Nair
Grap...

Table of contents

  1. Learning Shiny

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Learning Shiny by Hernan G. Resnizky in PDF and/or ePUB format, as well as other popular books in Computer Science & Open Source Programming. We have over one million books available in our catalogue for you to explore.