r语言 - 使用输入 $table_rows_selected 和选择输入打印图形(闪亮)



我使用第一个SQL查询来加载带有项目的selecInput列表

我在第一个SQL查询中创建了一个闪亮的图形,结果是将所选项目包含在选择输入列表中

然后我创建一个包含整个选择输入列表的数据表,我希望使用 input$table_rows_selected 函数(单击DT 表行视图(来更新此图

如何使用 selectInput 对象或 DT 表中的 input$table_rows_selected 函数跟踪图形?

现在,我可以从选择输入列表中跟踪我的图形

谢谢你的帮助

这是我的用户界面。R :

 sidebarPanel(
  uiOutput("selectComp") #My selectInput list
           ),
 mainPanel(
  DT::dataTableOutput("table"), #My Table 
  plotlyOutput("plot")) # My graph
   ))

这是我的服务器。R :

     refDataFrame <- reactive({
     data_testeur <- odbcConnect(input$base, uid="uid")
     SQL query searching all STEP_NAME items
     odbcClose(data_testeur)
    Ref_comp
   })
   output$selectComp <- renderUI(
      selectInput("comp","Select the step", choices= refDataFrame()
      [["STEP_NAME"]]) # Load the selecInput list with items
     ) 
     output$Table <- DT::renderDataTable({
     data_testeur <- odbcConnect(input$base, uid="uid")
      SQL query to feed my dataTable with a column including all items 
                                                             STEP_NAME
      Close connexion data_testeur
      DT::datatable(cpk_total,...) # Formating table
        )
  output$plot <- renderPlotly({
      data_testeur <- odbcConnect(input$base, uid="uid")
      another SQL query to trace the graph for 1 STEP_NAME selected
      Close connexion data_testeur
    graph <- ....
    )

如何使用 selectInput 对象或 DT 表中的 input$table_rows_selected 函数跟踪图形?

现在,我可以从选择输入列表中跟踪我的图形

谢谢你的帮助

如果我

理解正确,您希望从 selectInput 或从 input$ 中单击表格table_rows_selected

最后一个是NULL如果没有选择行,所以你应该在你的渲染函数中添加一些与此类似的代码

if(!is.null(input$table_rows_selected) ) { #test if table is clicked
  #do something with input$table_rows_selected
} else {
  #do something only with selectInput
}

希望这对其他明智有所帮助,请澄清您的问题

最新更新