library(shiny)
source("pausable.R")
# Define server logic required to give an output
shinyServer(function(input, output, session) {
#set reactive values
values <- reactiveValues(df_data = NULL)
#pause file upload
fileupload <- pauseableReactive(input$file1)
pauseFileUpload <- function(paused=TRUE){
pause(fileupload, paused)
}
#load and read csv
filedata <- reactive({
if(is.null(filedata)) return (NULL)
isolate({
pauseFileUpload(TRUE)
infile <- input$file1
read.csv(infile$datapath)
invokeLater(function(){
pauseFileUpload(FALSE)
}, 500)
})
#infile <- read.csv("KIRIMP.csv")
# outputOptions(output, 'fileUploaded', suspendWhenHidden=FALSE)
})
#render forumula withMathJax
output$mj1 <- renderUI({
withMathJax('$$\\frac{N_A}{N_B}=cr^2=\\frac{c(s + t - 1) ^2}{[(s + t -1) + \\frac{ 1 - t }{f_A}] [(s + t = 1) + \\frac{1 -s}{1-f_A}]}$$')
})
#observe the genes list and update genes drop down
observe({
values$df_data = filedata()
genesList = values$df_data[1]
updateSelectInput(session, "gene", "Genes ", unique(genesList))
})
#observe changes in the genes dropdown and update allele drop down
observeEvent(input$gene, {
cvsInput = filedata()
cvsInput.gene.sub <- as.data.frame(subset(cvsInput, Gene == input$gene, drop=FALSE, byrow=TRUE))
updateSelectInput(session, "allele", "Allele ", cvsInput.gene.sub[, 6])
})
#observe allele drop down and populate population drop down
observeEvent(input$allele, {
cvsInput = filedata()
cvsInput.allele.sub <- as.data.frame(subset(cvsInput, Allele == input$allele & Gene == input$gene, drop=FALSE, byrow=TRUE))
updateSelectInput(session, "population", "Population ", cvsInput.allele.sub[, 12])
})
#observe population drop down and show selected rows in text output
observeEvent(input$goButton, {
input$goButton
isolate({
cvsInput = filedata()
#perform formula calc
output$plot1 <- renderPlot({
plot(plotValue)
})# end render plot
}) # end isolate
})# end observeEvent(input$goButton)
})# end shiny server
The error I am getting is below, which makes me think that it's continuing to the observe function without waiting for the csv upload.