R 闪亮的';s选项卡集面板不在多个选项卡中显示绘图
我正在尝试在R 闪亮的';s选项卡集面板不在多个选项卡中显示绘图,r,tabs,plot,shiny,R,Tabs,Plot,Shiny,我正在尝试在中的tabsetPanel中使用多个tabPanel控件。假设我只从一个选项卡开始,使用以下代码: mainPanel( tabsetPanel( tabPanel("Plot",plotOutput("distPlot")) ) mainPanel( tabsetPanel( tabPanel("Plot",plotOutput("distPlot")), tabPanel("Plot",plotOutput("distPlot")
中的tabsetPanel
中使用多个tabPanel
控件。假设我只从一个选项卡开始,使用以下代码:
mainPanel(
tabsetPanel(
tabPanel("Plot",plotOutput("distPlot"))
)
mainPanel(
tabsetPanel(
tabPanel("Plot",plotOutput("distPlot")),
tabPanel("Plot",plotOutput("distPlot"))
)
代码运行正常,并在选项卡中显示绘图
但当我引入另一个选项卡来测试选项卡时,两个选项卡都停止显示任何绘图。我正在使用以下代码:
mainPanel(
tabsetPanel(
tabPanel("Plot",plotOutput("distPlot"))
)
mainPanel(
tabsetPanel(
tabPanel("Plot",plotOutput("distPlot")),
tabPanel("Plot",plotOutput("distPlot"))
)
请注意,我试图在两个选项卡中显示相同的绘图,只是为了测试选项卡是否工作。我得到的只是两个空白选项卡(如果我只使用一个选项卡,则绘图将正确显示)
有人能帮我解决这个问题吗?您将的“distPlot”
分配给plotOutput
的参数outputId
。“ID”表示此值在整个应用程序中必须是唯一的。您可以将相同的绘图指定给两个不同的plotOutput
s,但:
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") )
)
))
))
runApp(列表(
服务器=功能(输入、输出){
df我们也可以在一行中编写上述代码,如下所示
tabsetPanel(
tabPanel( "Plot", plotOutput("distPlot1"),plotOutput("distPlot2") )
)
这完全有道理。工作得很好。谢谢你的回答。