1

I've created a Shiny app using a fluid grid system (i.e., using fluidPage) that utilizes sidebarPanel and tabsetPanel. In addition to the input "control" widgets I put in the sidebar, I would also like to add a series of input widgets below the graphic in my main panel on a specific panel.

My approach was to simply include a fluidRow with multiple columns after the plotOutput command in the first tabPanel.

My code produces no errors, but for some reason nothing shows up under the graphic in my main panel.

Is this just not possible, or am I doing something wrong?

Note: this SO question suggests that my approach to including multiple UI elements within the tab is valid, and this SO question suggests that multiple outputs can be added to the mainPanel (but what about inputs??). So what gives??

Example code with same issue:

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)
2
  • Was your silhouette plot working. I get a blank plot, with no clusters, only text Apr 21, 2017 at 2:56
  • @vipin8169 unfortunately i still have never gotten silhouette plots to work. They always come up blank for me, too. I welcome you to open a question about this Apr 21, 2017 at 11:45

1 Answer 1

3

Certainly what you're trying to do is possible. When I run your example code, I actually do see the widgets underneath the plot (Lookup, Plot(s), Group(s), etc.). But I had to fix a couple of small things first--for one thing, you need to give a value to sliderInput. For another, you've got a misplaced bracket that's causing the mainPanel to be shoved into your sidebarPanel.

But there's no problem with your fluidRow itself, as written. Make sure you've put it in the right place in the UI.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.