My app allows users to upload their own data set. I have a function that checks it for errors; if it passes the check other aspects of the app can run (i.e. histograms, visualizations, etc). Here is what I'm currently trying:
shinyServer(function(input, output) {
in_data <- reactive({
inFile <- input$file1
if (is.null(inFile)) return(NULL)
read.csv(inFile$datapath, as.is=T)
})
check <- function(data){
failed <- T
error_list <- c()
#code that runs the check, adds errors to error_list
if(length(error_list) == 0) failed <- F
}
output$check <- renderText({
if (is.null(in_data())) return("Please upload a data set.")
check(in_data()) # should change "failed"
})
output$table <- renderTable({
if (is.null(in_data()) | failed) return()
# make the table
})
})
This exact code doesn't work because "failed" cannot be found by later functions trying to check its value. Even when I define "failed" outside of the check function, it isn't reactive -- if I upload one data set that fails and then another that passes, it doesn't act accordingly and run the other functions. I tried using reactiveValues() but couldn't get that to work either. Any tips?