Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 闪亮的';s选项卡集面板不在多个选项卡中显示绘图_R_Tabs_Plot_Shiny - Fatal编程技术网

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") )
)

这完全有道理。工作得很好。谢谢你的回答。