Commit 3870f715 authored by Aqeel Padaria's avatar Aqeel Padaria

show model fit on plot

parent 5a67d0fc
......@@ -336,11 +336,18 @@ server = shinyServer(
modname <- dataSelect()
original <- read.xlsx(datasetName, sheet = paste("d", modname, sep = "_"), colNames = TRUE, , check.names = FALSE)
original <- read.xlsx(datasetName, sheet = paste("d", modname, sep = "_"), colNames = TRUE, check.names = FALSE)
original$date <- as.Date(original$date, origin = "1899-12-30")
original <- data.frame(valdate = original$date, value = original[,input$metric])
thisoriginal <- paste(input$metric, input$testsplit, input$var, sep = "-")
if(!sum(grepl(" ", names(original))))
{
thisoriginal <- gsub(" ", ".", thisoriginal)
}
original <- data.frame(valdate = original$date, value = original[,input$metric], fit = original[,thisoriginal])
Models <- read.xlsx(datasetName, sheet = paste("m", modname, sep = "_"), colNames = TRUE)
......@@ -362,7 +369,7 @@ server = shinyServer(
timeband <- ifelse(timeval=="days", 1, ifelse(timeval=="weeks", 7, ifelse(timeval=="months", 30, ifelse(timeval=="years", 365, 1))))
newvals <- data.frame(valdate = seq.Date(max(original$valdate+timeband), by = timeval, length.out = length(pointforecast)), value = NA, newval = pointforecast, hi95 = hi95, hi80 = hi80, lo95 = lo95, lo80 = lo80)
newvals <- data.frame(valdate = seq.Date(max(original$valdate+timeband), by = timeval, length.out = length(pointforecast)), value = NA, fit = NA, newval = pointforecast, hi95 = hi95, hi80 = hi80, lo95 = lo95, lo80 = lo80)
original$newval <- NA
original$hi95 <- NA
......@@ -372,7 +379,7 @@ server = shinyServer(
totalvals <- rbind(original, newvals)
ggplot(totalvals, aes(valdate, value, group = 1)) + geom_line() + geom_line(inherit.aes = FALSE, aes(valdate, newval), colour = "blue") + geom_ribbon(data=totalvals, aes(ymin=hi95,ymax = lo95), alpha=0.1, fill="blue") + geom_ribbon(data=totalvals, aes(ymin=hi80,ymax = lo80), alpha=0.3, fill="blue") + labs(x="Time", y="Values") + scale_x_date(limits = c(min(totalvals$valdate), max(totalvals$valdate)))
ggplot(totalvals, aes(valdate, value, group = 1)) + geom_line() + geom_line(inherit.aes = FALSE, aes(valdate, fit), colour = "blue") + geom_line(inherit.aes = FALSE, aes(valdate, newval), colour = "blue") + geom_ribbon(data=totalvals, aes(ymin=hi95,ymax = lo95), alpha=0.1, fill="blue") + geom_ribbon(data=totalvals, aes(ymin=hi80,ymax = lo80), alpha=0.3, fill="blue") + labs(x="Time", y="Values") + scale_x_date(limits = c(min(totalvals$valdate), max(totalvals$valdate)))
} else if(input$var=="All")
plot(1, axes=FALSE, xlab='', ylab='', pch='')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment