Skip to content

Instantly share code, notes, and snippets.

@danslimmon

danslimmon/server.R

Created Oct 11, 2013
Embed
What would you like to do?
The server part of my error-tracking Shiny app.
library(shiny)
# Load the data from our CSV file
logfreq <- read.csv('portalserr.csv')
logfreq$date <- as.POSIXct(logfreq$date)
# Calculate error rate per thousand accesses
logfreq$perthou <- logfreq$error.count / logfreq$access.count * 10^3
shinyServer(function(input, output) {
output$freqPlot <- renderPlot({
if (is.null(input$errors_shown)) {
# If no checkboxes are checked, dislay an empty plot.
print(ggplot(data.frame(x=c(0),y=c(0))) + geom_point(aes(x,y), alpha=0))
} else {
lf.filtered <- subset(logfreq, error.id %in% input$errors_shown)
p <- ggplot(lf.filtered) +
geom_point(aes(date, perthou, color=error.id), size=3) +
geom_line(aes(date, perthou, color=error.id, group=error.id), size=2) +
expand_limits(ymin=0) +
theme(legend.position='left') +
ggtitle('Errors per thousand requests') +
ylab('Errors per thousand requests') +
xlab('Date')
print(p)
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.