如果一个反应值发生变化而另一个反应值没有变化,则重绘一次?

时间:2017-10-30 14:40:48

标签: r shiny

我有两个被动值input$codeinput$variants,如果满足以下任何条件,我想重绘一次。

  1. 代码更改和变体更改
  2. 代码更改和变体不会更改
  3. 代码不会更改和变体更改
  4. 我无法在renderPlotly中同时调用input$codeinput$variants,否则将为上面的#1重绘两次。

      output$choose_test <- renderUI({
        data_sets <- loadTest()
        selectizeInput(
          'test', 'Test', choices = data_sets$test, selected = data_sets$test[1]
        )
      })
    
      output$choose_code <- renderUI({
        validate(
          need(input$test, 'Please choose a test.')
        )
    
        code <- loadCode(input$test)
        selectizeInput(
          'code', 'Code', choices = code$code, selected = code$code[1]
        )
      })
    
      output$choose_variants <- renderUI({
        validate(
          need(input$test,  'Please choose a test.'),
          need(input$code,   'Please choose a code.')
        )
    
        dat <- loadVariants(input$test, input$code)
    
        default_select <- dat$variant[grep('v1|v2', dat$variant)]
        if (identical(default_select, factor(0))) {
          default_select <- dat$variant[1]
        }
    
        checkboxGroupInput("variants", "Variants",
                            choices  = dat$variant,
                            selected = default_select)
      })
    
      output$plot1 <- renderPlotly({
    
        runLocations <- isolate(loadRunsBetweenDates(input$test, input$code, input$variants))
    
        total_min_df <-
          runLocations %>%
          group_by(change_number, variant) %>%
          summarize(memory = min(memory))
    
        total_min_df$change_number <- as.numeric(as.character(total_min_df$change_number))
    
        p <- ggplot(total_min_df,
               aes(x=change_number,
                   y=memory,
                   group=variant,
                   color=variant))+
        geom_point()+
        geom_smooth(se = FALSE)+
        scale_x_continuous(labels = function(n){format(n, scientific = FALSE)})+
        scale_y_continuous(labels = function(n){format(n, scientific = FALSE)})+
        labs(x = "Change Number", y = "Megabytes")
    
        ggplotly(p)
      })
    

0 个答案:

没有答案