2017-12-27 10 views
0

ShinyアプリのmainPanelに複数のtabsetPanelを含めるようにしています。私がアプリケーションを起動すると、アプリケーションがサーバー要素にまったく入ることなくUI要素を把握しようとしているかのように何も表示されません。シャイニーは複数のタブセットパネルに反応しません

なぜこのような場合がありますか?

以下は、RStudioのShinyアプリケーションテンプレートに基づく最小限の例です。

ui.R

library(shiny) 

# Define UI for application that draws a histogram 
shinyUI(fluidPage(

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
    sidebarPanel(
     sliderInput("bins", 
        "Number of bins:", 
        min = 1, 
        max = 50, 
        value = 30) 
    ), 

    # Multiple tabset panels 
    mainPanel(
     h2("tabsetpanel1"), 
     tabsetPanel(id = "pan1", 
        type = "tabs", 
        tabPanel("tab1", plotOutput("distPlot"))), 
     h2("tabsetpanel2"), 
     tabsetPanel(id = "pan2", 
        type = "tabs", 
        tabPanel("tab2", plotOutput("distPlot"))) 
    ) 
) 
)) 

server.R

あなたの出力は、あなたカントは、複数の "distPlot"を持っている固有のもので、このようなものに変更する必要が
library(shiny) 

# Define server logic required to draw a histogram 
shinyServer(function(input, output) { 

    output$distPlot <- renderPlot({ 

    # generate bins based on input$bins from ui.R 
    x <- faithful[, 2] 
    bins <- seq(min(x), max(x), length.out = input$bins + 1) 

    # draw the histogram with the specified number of bins 
    hist(x, breaks = bins, col = 'darkgray', border = 'white') 

    }) 

}) 

答えて

0

data <- reactive({ 
    # generate bins based on input$bins from ui.R 
    x <- faithful[, 2] 
    bins <- seq(min(x), max(x), length.out = input$bins + 1) 

    # draw the histogram with the specified number of bins 
    hist(x, breaks = bins, col = 'darkgray', border = 'white') 
}) 

    output$distPlot1 <- renderPlot({ 
    data() 
    }) 

    output$distPlot2 <- renderPlot({ 
    data() 
    }) 

次にあなたのものui

plotOutput("distPlot1") 

plotOutput("distPlot2") 
関連する問題