【问题标题】:fluidRow won't appear under mainPanel graphic in Shiny在 Shiny 中,fluidRow 不会出现在 mainPanel 图形下
【发布时间】:2017-06-03 03:48:54
【问题描述】:

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

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

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

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

注意:SO question 表明我在选项卡中包含多个 UI 元素的方法是有效的,而 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)

【问题讨论】:

  • 你的剪影图是否有效。我得到一个空白图,没有集群,只有文本
  • @vipin8169 不幸的是,我仍然没有让剪影图起作用。他们对我来说也总是空白。欢迎您就此提出问题

标签: r layout shiny fluid-layout


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2018-12-04
    • 1970-01-01
    • 2020-07-09
    • 2019-02-10
    • 1970-01-01
    • 2019-06-21
    • 2016-07-21
    • 2022-01-28
    • 2019-03-14
    相关资源
    最近更新 更多