0

Prior to adding the conditional selectInput, I had a reactive statement that updated when a new pair was chosen. It worked as intended. Now that I added the conditional selectInput r shiny doesn't seem to ever run the reactive statement (as evidenced by no console printouts). I though shiny was supposed to update a reactive statement whenever one of it's input dependencies change, but this is clearly not working:

UI:

binancePAIRS <- c('ADABTC', 'BCCBTC', 'BNBBTC', 'BNBUSDT', 'BTCUSDT', 'EOSBTC', 'ETHBTC', 'ETHUSDT', 'ICXBTC', 'IOTABTC', 'LTCBTC', 'NEOBTC', 'OMGBTC', 'ONTBTC', 'TRXBTC', 'VENBTC', 'XLMBTC', 'XMRBTC', 'XRPBTC')
bitfinexPAIRS <- c('BCHUSD', 'BTCUSD', 'EOSUSD', 'ETHUSD', 'LTCUSD')
dashboardSidebar(
      #sliderInput("bins", "Number of Breaks",1,100,50),
      sidebarMenu(
        # menuItem("Dashboard1", tabName='dashboard1', icon=icon('dashboard')),
        selectInput('exchangeAinput' , label='exA', choices=c('binance', 'bitfinex'), selected = 'binance'),
        conditionalPanel(condition = "input.exchangeAinput == 'binance'", selectInput('pairAbinance', label = 'Pair A', choices = binancePAIRS, selected= 'BTCUSDT')),
        conditionalPanel(condition = "input.exchangeAinput == 'bitfinex'", selectInput('pairAbitfinex', label = 'Pair A', choices = bitfinexPAIRS, selected= 'BTCUSD')),

        selectInput('exchangeBinput' , label='exB', choices=c('binance', 'bitfinex'), selected = 'binance'),
        conditionalPanel(condition = "input.exchangeBinput == 'binance'", selectInput('pairBbinance', label = 'Pair B', choices = binancePAIRS, selected= 'BTCUSDT')),
        conditionalPanel(condition = "input.exchangeBinput == 'bitfinex'", selectInput('pairBbitfinex', label = 'Pair B', choices = bitfinexPAIRS, selected= 'BTCUSD'))
      )
      ),

Server:

shinyServer(function(input, output){
  pairA <- reactive({
    print('it A')
    if(input$exchangeAinput %in% c('binance')){
    print(input$pairAbinance)
    exA <- 'binance'
    nameA <- input$pairAbinance
    print(exA)
    print(nameA)
    as.data.frame(fread(rawToChar(get_object(paste0("s3://info-datasets/binance-", nameA, "/small", nameA, ".csv")))))
     }else{exA <- 'bitfinex'
       nameA <- input$pairAbitfinex
       print(exA)
       print(nameA)
       as.data.frame(fread(rawToChar(get_object(paste0("s3://info-datasets/bitfinex-", nameA, "/small", nameA, ".csv")))))} 
    })

  pairB <- reactive({
    print('it B')
    if(input$exchangeBinput == 'binance'){
    exB <- 'binance'
    nameB <- input$pairBbinance
    print(exB)
    print(nameB)
    as.data.frame(fread(rawToChar(get_object(paste0("s3://info-datasets/binance-", nameB, "/small", nameB, ".csv")))))
    }else{exB <- 'bitfinex'
      nameB <- input$pairBbitfinex
      print(exB)
      print(nameB)
      as.data.frame(fread(rawToChar(get_object(paste0("s3://info-datasets/bitfinex-", nameB, "/small", nameB, ".csv")))))} })

  nlpA <- reactive({as.data.frame(fread(rawToChar(get_object(paste0("s3://info-datasets/", exA, "-", nameA, "/sync/tracker.csv")))))})
  nlpB <- reactive({as.data.frame(fread(rawToChar(get_object(paste0("s3://info-datasets/", exB, "-", nameB, "/sync/tracker.csv")))))})

Since no print messages make it to console, that means either the selectInput 'input$pairAbinance' variables are never be updated or the server is completely missing updates to input$pairAbinance or input$pairAexchange

Garglesoap
  • 565
  • 6
  • 18
  • When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Make sure all variables are defined (`binancePAIRS` is not for example) – MrFlick Jul 12 '18 at 21:04
  • Thanks, binancePAIRS / bitfinexPAIRS are the first things set, outside of shinyUI() – Garglesoap Jul 12 '18 at 23:21
  • If that does not work with `conditionalPanel` (I don't know why), you could use a `renderUI` instead. – Stéphane Laurent Jul 13 '18 at 12:55
  • I've tried your code (verbatim). For me it works. Indeed nothing is printed in the console; a possible reason is that `pairA` and `pairB` are never called. – Stéphane Laurent Jul 13 '18 at 13:13

0 Answers0