如果满足条件,R-shiny 会显示某些情节
R-shiny show certain plot if conditions are met
在我的 server.R 我有:
output$interactive <- renderIHeatmap(...
output$static <- renderPlot(...
这两种渲染热图,一种是交互式的,一种是静态的。如果热图的行或列维度大于特定数字,有没有一种方法可以让 shiny 自动选择显示静态热图?所以像...
box(width = NULL, solidHeader = TRUE,
if (heatmap_rows<100) {
iHeatmapOutput('interactive')
} else {
plotOutput('static')
})
感谢您的宝贵时间。如果不清楚,我深表歉意。
您要查找的是 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 后面。
在我的 server.R 我有:
output$interactive <- renderIHeatmap(...
output$static <- renderPlot(...
这两种渲染热图,一种是交互式的,一种是静态的。如果热图的行或列维度大于特定数字,有没有一种方法可以让 shiny 自动选择显示静态热图?所以像...
box(width = NULL, solidHeader = TRUE,
if (heatmap_rows<100) {
iHeatmapOutput('interactive')
} else {
plotOutput('static')
})
感谢您的宝贵时间。如果不清楚,我深表歉意。
您要查找的是 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 后面。