Book Image

Web Application Development with R Using Shiny Second Edition - Second Edition

By : Chris Beeley
Book Image

Web Application Development with R Using Shiny Second Edition - Second Edition

By: Chris Beeley

Overview of this book

R is a highly flexible and powerful tool for analyzing and visualizing data. Most of the applications built using various libraries with R are desktop-based. But what if you want to go on the web? Here comes Shiny to your rescue! Shiny allows you to create interactive web applications using the excellent analytical and graphical capabilities of R. This book will guide you through basic data management and analysis with R through your first Shiny application, and then show you how to integrate Shiny applications with your own web pages. Finally, you will learn how to finely control the inputs and outputs of your application, along with using other packages to build state-of-the-art applications, including dashboards.
Table of Contents (14 chapters)
Web Application Development with R Using Shiny Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Notifications


The ability to create notifications is part of a larger amount of functionality within shinydashboard, which allows you to create messages, tasks, and notifications in the header of your dashboard. For more details, visit rstudio.github.io/shinydashboard/structure.html.

In this example, we will just add notifications. The code is very similar to the other two types of content. On the server.R side, the code is as follows:

output$notifications <- renderMenu({

This line allows the notification content to be rendered dynamically and called in the ui.R file with dropdownMenuOutput("notifications"). We have the following code:

  users <- sum(gadf[gadf$date == max(gadf$date), "users"])
  newusers <- sum(gadf[gadf$date == max(gadf$date), "newUsers"]) /
  sum(gadf[gadf$date == max(gadf$date), "users"])
  * 100

These lines calculate the two values that we want— the number of users in the time period and the percentage of new users. We have the following code:

  newusers <- round...