我正在尝试使用多个tabPanel
控制范围内的tabsetPanel
in Shiny
。假设我使用以下代码从一个选项卡开始:
mainPanel(
tabsetPanel(
tabPanel("Plot",plotOutput("distPlot"))
)
代码运行良好并在选项卡中显示绘图。
但是当我引入另一个选项卡只是为了测试选项卡时,两个选项卡都停止显示任何绘图。我正在使用以下代码:
mainPanel(
tabsetPanel(
tabPanel("Plot",plotOutput("distPlot")),
tabPanel("Plot",plotOutput("distPlot"))
)
请注意,我试图在两个选项卡中显示相同的绘图,只是为了测试选项卡是否有效。我得到的只是两个空白选项卡(如果我只使用一个选项卡,绘图将正确显示)。
有人可以帮我解决这个问题吗?
你分配"distPlot"
to plotOutput
的参数outputId
。 “ID”表示该值在整个闪亮应用程序中必须是唯一的。您可以将相同的图分配给两个不同的plotOutput
不过:
runApp( list(
server = function(input, output) {
df <- data.frame( x = rnorm(10), y = rnorm(10) )
output$distPlot1 <- renderPlot({ plot( df, x ~ y ) })
output$distPlot2 <- renderPlot({ plot( df, x ~ y ) })
},
ui = fluidPage( mainPanel(
tabsetPanel(
tabPanel( "Plot", plotOutput("distPlot1") ),
tabPanel( "Plot", plotOutput("distPlot2") )
)
))
))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)