1

My app works totally fine locally. When I deploy to shinyapps.io the selectInput doesn't show up. I have checked the logs. There is no error. The "h" is printed so the app is definitely reading it. However, nothing is displayed. The app works after I switch tabs and then click randomly somewhere. I have to do this everytime an observeEvent should take care of things. This is not a problem locally. I have tried testing it on other machines and it works fine. The only problem arises when I upload to shinyapps.io. Any help would be very appreciated. Thank you.

        ext <- tools::file_ext(file$datapath)
        req(file)
        validate(need(ext == "csv", "Please upload a csv file"))
        table_inp <<- read.csv(file$datapath, header = input$header, fileEncoding="UTF-8-BOM") #fileEncoding="UTF-8-BOM"
        # read.csv(file$datapath)
        # })
        
      
        
        #If type of interaction is selected
        #Select type of interaction for higher order terms
        shinyjs::show(output$s_order <- renderUI({
            print("h")
            selectInput("select_order", "Higher Order Terms", c("None", "Two-way Interaction", "Three-way Interaction", "Polynomial Interaction"), selected = "None")
        }))
X L
  • 27
  • 5
  • Can you please clarify when does the selectInput is supposed to show? What is type of interaction? – jpdugo17 Jan 02 '22 at 02:18
  • 1
    @jpdugo17 This block of code is inside an observeEvent for the file input. So the selectInput should display after the file is inputted. – X L Jan 02 '22 at 13:08

1 Answers1

0

We can try this:

library(shiny)
library(shinyjs)

ui <- fluidPage(
  useShinyjs(),
  fileInput("file", label = "Select Csv", accept = c(".csv")),
  checkboxInput("header", "Header", value = TRUE),
  hidden(selectInput("select_order", "Higher Order Terms", c("None", "Two-way Interaction", "Three-way Interaction", "Polynomial Interaction"), selected = "None"))
)

server <- function(input, output, session) {
  table_inp <- reactive({
    ext <- tools::file_ext(input$file$name)
    validate(need(ext == "csv", "Please upload a csv file"))
    read.csv(file$datapath, header = input$header, fileEncoding = "UTF-8-BOM") # fileEncoding="UTF-8-BOM"
  })


  observe({
    req(input$file)
    if (tools::file_ext(input$file$name) == "csv") {
      show("select_order")
    } else {
      validate("Please upload a csv file")
    }
  })
}

shinyApp(ui, server)
jpdugo17
  • 6,816
  • 2
  • 11
  • 23
  • Thanks for the response. It is giving me the same issue. I discovered that if I upload the file and then wait for about 5 minutes, then everything loads properly and functions normally. However, there is no wait time on my laptop or on any other machine on which I have tested the app. – X L Jan 11 '22 at 21:31