【问题标题】:R Shiny: Conditional panel based on row selected in datatableR Shiny:基于数据表中选择的行的条件面板
【发布时间】:2016-10-06 03:59:59
【问题描述】:

我是 Shiny 的新手。我想根据我在数据表中选择的行获得一个新面板。到目前为止,我已经添加了以下代码,但它似乎不起作用。您必须设置什么条件才能显示新面板并删除以前的面板?

library(shiny)

ui <- fluidPage(

conditionalPanel(
condition <- "is. null(input.dt_rows_selected) == TRUE",
DT::dataTableOutput(outputId = "dt")
),
  conditionalPanel(
condition <- "is. null(input.dt_rows_selected) == FALSE" ,
h3("Plots based on the selected row ")
)
)


server <- function(input, output){

output$dt <- DT::renderDataTable(
mtcars, server = FALSE, selection = 'single'
)
}


shinyApp(ui =ui, server = server)

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    您需要检查两个选项:

    1) 输入存在

    2) 输入 >0

    喜欢:

    conditionalPanel(
        condition ="typeof input.dt_rows_selected  === 'undefined' || input.dt_rows_selected.length <= 0",
        DT::dataTableOutput(outputId = "dt"))
      ,
      conditionalPanel(
        condition = "typeof input.dt_rows_selected  !== 'undefined' && input.dt_rows_selected.length > 0" ,
        h3("Plots based on the selected row ")
      )
    

    选择行 DT 隐藏并显示文本后

    【讨论】:

    • 非常感谢。这正是我想要的:)
    猜你喜欢
    • 1970-01-01
    • 2016-08-14
    • 1970-01-01
    • 2016-06-04
    • 2021-07-09
    • 2022-01-26
    • 1970-01-01
    • 2016-09-29
    • 2015-07-07
    相关资源
    最近更新 更多