How to bring two plots like Plotoutput and tableoutput together into a shiny dashboard

Hi,

I am unable fit in two output tableoutput and a plotoutput into a single dashboard. when I am outputing only Plotoutput then it is working fine but when I am trying to make both the output together then Tableoutput is appearing well but plotoutput is not appearing.

Please find my code below:

query_detail <- read_excel("Query Detail.xls")
# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("Queries Dashboard"),

     
    dashboardSidebar(
        sidebarPanel(
            sliderInput("bins",
                        "Number of bins:",
                        min = 1,
                        max = 20,
                        value = 10)
        ),
       
        dashboardBody(
            fluidRow(box(plotOutput("distPlot"))),
            fluidRow(box(tableOutput("QueryDetail")))           
           
        )
    )
)

server <- function(input, output) {
    output$distPlot <- renderPlot({
        query_detail %>% filter(`Query Text` != "The field is required. Please complete.") %>% 
            group_by(Form, Field, `Query Text`) %>% 
            summarise(number_of_times = n()) %>% filter(number_of_times != 1) %>%
            arrange(desc(number_of_times)) %>% ungroup() %>% 
            mutate(Check_order_ID = row_number()) %>%
        filter(number_of_times >= input$bins) %>%
        ggplot(aes(x= Check_order_ID, y=number_of_times, fill=Field), height = 50, width = 200) +
            geom_bar(stat="identity", position=position_dodge()) + facet_wrap(~Form) +
            theme(axis.text = element_text(size = 10))
      
        output$QueryDetail <- function(){
            query_detail %>% filter(`Query Text` != "The field is required. Please complete.") %>% 
                group_by(Form, Field, `Query Text`) %>% 
                summarise(number_of_times = n()) %>% filter(number_of_times != 1) %>%
                arrange(desc(number_of_times)) %>% ungroup() %>% 
                mutate(Check_order_ID = row_number()) %>%
                filter(number_of_times >= input$bins) %>% kable() %>% kable_styling() %>% scroll_box(height = "100px", width = "800px")
            
        }  
    
    })
}

Hi,
Code was not working because of some parenthesis problem. Thanks.

Regards,
Arunabha

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  header = dashboardHeader(),
  sidebar =
    dashboardSidebar(
      sliderInput("bins",
        "Number of bins:",
        min = 1,
        max = 20,
        value = 10
      )
    ),
  body = dashboardBody(
    fluidRow(box(plotOutput("distPlot"))),
    fluidRow(box(tableOutput("QueryDetail")))
  ),
  title = "Queries Dashboard"
)

server <- function(input, output, session) {
  output$distPlot <- renderPlot({
    plot(iris$Sepal.Length, iris$Sepal.Width)
  })
  output$QueryDetail <- renderTable({
    iris
  })
}

shinyApp(ui, server)

Thanks a lot. It really helps.

Hi Nir,

Could you please help me in this code, i am trying to create two tabs in the dashboard. But nothing is appearing apart from sidebar panel. Thanks a lot for your previous solution, It worked.

ui <- dashboardPage(
header = dashboardHeader(title = "Queries Dashboard"),
sidebar =
dashboardSidebar(width=150, sidebarMenu(
menuItem("RAVE Query",tabName = "RAVEQueryDetail",
sliderInput("bins",
"Number of bins:",
min = 1,
max = 20,
value = 10
)),
menuItem("ARMADA",tabName = "ARMADAEditChecks")

    )),

dashboardBody(
    tabItems(
        tabItem(
            tabName = "RAVEQueryDetail",
            fluidRow(box(width=4, plotOutput("Marking_gr", width="200px",height="200px")), box(width=8, plotOutput("distPlot", width="500px",height="300px"))),
            fluidRow(box(tableOutput("QueryDetail"))),
            
        ),
        tabItem(tabName = "ARMADAEditChecks")
    )
)

)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.