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

Google Charts gauge


The gauge in the middle of the screen with the bounce rate is from the excellent Google Charts API. More information on this can be found at developers.google.com/chart/. Fortunately for us, there is an R package to interface with Google Charts, so there is no need to get our hands dirty with a different API. The package is on CRAN and can be installed with install.packages("googleVis").

The code is as follows:

output$gauge <- renderGvis({
  df <- data.frame(Label = "Bounce %",
    Value = round(mean(passData()$bounceRate,
      trim = .1), 1)
  )
  gvisGauge(df,
    options = list(min = 0, max = 100,
      greenFrom = 0,
      greenTo = 50, yellowFrom = 50,
      yellowTo = 70,
      redFrom = 70, redTo = 100)
  )
})

A data frame is produced, with the first column being the label for the gauge, and the second, the value of the gauge. If you require more than one gauge, simply include multiple rows. In this case, we will just use one row. The gauge is drawn very simply...