I'm using the dismo::maxent
function to create plots, but the problem is they can take a really long time (a few minutes). I want to have two tabs, one with a plot of the map and likelihoods and another one showing variable importance. This is working, but I want a wait message/plot/screen on both tabs while model is running. It's 2 function calls, there is no loop, so a placeholder message is all I need. It would need to be displayed after the submit button is pressed each time but not there initially.
Here's the server.R
data <- read.csv("CFR_Vaccine_Map_Corrected.csv")
load("./bioclim_10m.Rdata")
shinyServer(
function(input, output) {
observe({
if (!(is.null(input$checkGroup))) {
print(input$years)
print(input$checkGroup)
year.range <- input$years[1]:input$years[2]
filtered.cases <- which(data$Outbreak %in% input$checkGroup &
data$Year %in% year.range)
maxent.model <- maxent(bioStack, data[filtered.cases,5:4])
print("model comp")
maxent.map <- predict(maxent.model, bioStack)
print("plotting map")
output$map <- renderPlot({
plot(maxent.map, xlab="Longitude", ylab="Latitude")
})
output$significance <- renderPlot({
plot(maxent.model)
})
}
})
}
)
and here's the ui.R
shinyUI(fluidPage(
titlePanel("Vaccine-Preventable Outbreaks"),
sidebarLayout(
sidebarPanel(
helpText("Create maximum entropy maps with information from
Council on Foreign Relations data on vaccine-preventable
outbreaks."),
checkboxGroupInput("checkGroup", h3("Category"),
choices = list("Polio" = "Polio",
"Whooping Cough" = "Whooping Cough",
"Measles" = "Measles",
"Mumps" = "Mumps",
"Rubella" = "Rubella",
"Polio" = "Polio",
"Violence" = "Violence")),
sliderInput("years", "Years of interest:",
min = 2007, max = 2016, value = c(2007, 2016), sep=""),
submitButton("Submit")
),
mainPanel(
tabsetPanel(
tabPanel("Map", plotOutput("map")),
tabPanel("Variable Significance", plotOutput("significance"))
)
)
)
))