【问题标题】:R-shiny show certain plot if conditions are met如果满足条件,R-shiny 显示某些情节
【发布时间】:2015-10-18 07:21:08
【问题描述】:

在我的 server.R 中,我有:

output$interactive <- renderIHeatmap(...

output$static <- renderPlot(...

这两种渲染热图,一张是交互式的,一张是静态的。如果热图的行或列尺寸大于特定数字,闪亮可以自动选择显示静态热图吗?所以像......

box(width = NULL, solidHeader = TRUE,
      if (heatmap_rows<100) {
         iHeatmapOutput('interactive')
      } else  {
         plotOutput('static')
      })

感谢您的宝贵时间。如果不清楚,我深表歉意。

【问题讨论】:

    标签: user-interface shiny heatmap


    【解决方案1】:

    您正在寻找的是 conditionalPanel()。

    在server.R中,你需要做一个输出变量,即行数:

    shinyServer(function(input,output,session){
      output$heatmap_rows <- renderText(nrow(heatmap_data))
    }
    

    在您的 ui.R 中,您需要在某处显示该输出。您可能可以使用 .css 巧妙地隐藏它,但它必须实际进入页面的 html,否则您将无法使用 conditionalPanel 对其进行条件处理。

    这是 ui.R 中的总体思路:

    shinyUI(fluidPage(
      mainPanel(
    
        #Note the output.heatmap_rows syntax. That's JavaScript.
        conditionalPanel("output.heatmap_rows < 100", 
                         iHeatmapOutput('interactive')
        ),
        conditionalPanel("output.heatmap_rows >= 100",
                         plotOutput('static')
        )
      ),
    
      #This has to be somewhere on the page, and it has to render.
      #Alter the css and make its' text the same color as the background.
      verbatimTextOutput("heatmap_rows")
    
    ))
    

    我还没有找到更好的方法来处理输出中的数据。您也可以将所有这些逻辑隐藏在 server.R 中的 uiRender 后面。

    【讨论】:

      猜你喜欢
      • 2014-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多