fluidRow 不会出现在 Shiny 的 mainPanel 图形下

fluidRow won't appear under mainPanel graphic in Shiny

我使用流体网格系统(即使用 fluidPage)创建了一个闪亮的应用程序,该系统利用了 sidebarPaneltabsetPanel。除了我放在侧边栏中的输入 "control" 小部件外,我还想在特定面板上的主面板中的图形 下方 添加一系列输入小部件。

我的方法是在第一个 tabPanel 中的 plotOutput 命令之后简单地包含一个具有多个列的 fluidRow

我的代码没有产生任何错误,但由于某种原因 没有任何东西 显示在我的主面板的图形下方。

这是不可能的,还是我做错了什么?

注意:这个SO question suggests that my approach to including multiple UI elements within the tab is valid, and this SO question建议可以将多个输出添加到主面板(但是输入呢??)。那么是什么给了??

具有相同问题的示例代码:

library(shiny)

ui <- fluidPage(

  titlePanel(
    h1("NMS Comparing tool", style = "font-size: 15px")
  ),


  sidebarPanel(width = 3,
           div(style = "font-size: 8px;", 
               sliderInput(inputId = "groups", 
                           label = "No. of Groups",
                           value = 4, min = 2, max = 12)
           ),  

           fluidRow(
             column(6,offset=0,
                    div(style = "height: 105px; padding: 0px 0px",
                        plotOutput(outputId = "scree")
                    )
             ),

             column(6,offset=0,
                    div(style = "font-size: 8px;padding: 0px 10px;height: 105px",
                        checkboxGroupInput(inputId = "labels",
                                           label = "Labels",
                                           choices = c("SPEC","Plot-End","Plot-Start"),
                                           selected = c("SPEC","Plot-End","Plot-Start")
                        )    
                    )
             )
           ),

           fluidRow(
             column(6,offset=0,
                    div(style = "font-size: 8px; padding: 0px 0px",      
                        radioButtons(inputId = "data",
                                     label = "Data",
                                     choices = c("PSP Only","PSP + MAP"),
                                     selected = "PSP + MAP")
                    )    
             ),

             column(6,offset=0,
                    div(style = "font-size: 8px;padding: 0px 10px;",  
                        radioButtons(inputId = "freq",
                                     label = "Frequency",
                                     choices = c(0.025,0.05),
                                     selected = 0.05)
                    )
             )
           ),

           fluidRow(
             column(6,offset=0,
                    div(style = "font-size: 8px; padding: 0px 0px; ",                 
                        radioButtons(inputId = "arrows",
                                     label = "Vector Choice",
                                     choices = c("Cumulative Change","All Samples","Hurricane"),
                                     selected = "Cumulative Change")
                    )
             ),

             column(6,offset=0,
                    div(style = "font-size: 8px;padding: 0px 10px",      
                        selectInput(inputId = "size",
                                    label = "Tree Size",
                                    choices = c("All","Canopy","Subcanopy","Small"),
                                    selected = "All"),
                        tags$style(type = "text/css",
                                   "#size {height: 4px; }")
                    )
             )
           ),

           fluidRow(
             div(style = "font-size: 8px;",                 
                 verbatimTextOutput("info")
             )    
           )
           ,

           mainPanel(width = 9,
                     tabsetPanel(
                       tabPanel(title = "NMS", 
                                plotOutput(outputId = "nms", click = "plot_click"),
                                fluidRow(
                                  column(2,offset=0,
                                         div(style = "font-size: 8px; padding: 0px 0px", 
                                             actionButton(inputId = "plot.singles", label = "Lookup")
                                         )
                                  ),
                                  column(2,offset=0,
                                         div(style = "font-size: 8px; padding: 0px 0px",     
                                             textInput(inputId = "individ", label = "Plot(s)")
                                         )
                                  ),
                                  column(2,offset=0,
                                         div(style = "font-size: 8px; padding: 0px 0px", 
                                             textInput(inputId =  "group.choose", label = "Group(s)")
                                         )
                                  ),
                                  column(3,offset=0,
                                         div(style = "font-size: 8px; padding: 0px 0px", 
                                             sliderInput(inputId = "lwidth.choose", label = "LineWidth",min = 1, max = 6)
                                         )
                                  )
                                )
                       ),
                       tabPanel(title = "Silhouette", plotOutput(outputId = "silhouette")),
                       tabPanel(title = "Indicator Spp", dataTableOutput(outputId = "ind.spp")),
                       tabPanel(title = "Data", dataTableOutput(outputId = "nms.data.table"))
                     )
           )
  )
)


server <- function(input, output) {

 output$scree <- renderPlot({

    par(mar = c(1.5,1.4,0.1,0.1), mgp = c(0.5,0.01,0), tcl = -0.1)
    plot(runif(99),runif(99),cex.axis=0.5,cex.lab=0.5,cex=0.75)

  },height = 95, width = 135) 

  output$nms <- renderPlot({

    plot(runif(99),runif(99))

  })

}

shinyApp(ui = ui, server = server)

当然,您尝试做的事情是可行的。当我 运行 你的示例代码时,我确实看到了绘图下方的小部件(查找、绘图、组等)。但我必须先解决一些小问题——一方面,您需要为 sliderInput 赋值。另一方面,你有一个错位的括号导致 mainPanel 被推入你的 sidebarPanel.

但是您的 fluidRow 本身没有问题,如所写。确保您已将其放在 UI.

中的正确位置