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