Dynamic ggvis object in Shiny

后端 未结 1 1140
迷失自我
迷失自我 2021-01-14 13:08

I\'m trying to add a dynamic ggvis plot to a Shiny app. First, user picks a dimension, and then adds items from that dimension.

For global.R and sample data, see ht

相关标签:
1条回答
  • 2021-01-14 13:40

    The error is caused because you have a data.frame with zero rows and have a resulting 1:0. You can change your selected function to:

     selected <- reactive({
        if (is.null(input$items)) {
          return(aalto_all)
        }
        df <- aalto_all[aalto_all[[input$dim]] %in% input$items, ]
        df$keys <-seq_along(df[,1])
        if(nrow(df) == 0){
          return(aalto_all)
        }
        df
      })
    
    0 讨论(0)
提交回复
热议问题