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 ...

Get Web Application Development with R Using Shiny - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.