shinydashboardgolem

Error: argument "body" is missing, with no default


I am dealing with an issue for several hours, please do not punish me on points. tried pretty much everything was suggested on stack overflow. I use golem library to build up the app, thus please be aware of this aspect. Also, if you want to look on the wider code here is the branch I am working on github:

https://github.com/gabrielburcea/bftb

I put a snippet of the code where the error takes place:

app_server <- function(input, output, session) {
  shiny::callModule(mod_tools_server, "tools_path_ui_1")
  shiny::callModule(mod_gene_expressions_sign_path_server, "gene_expression_sign_path_ui_1")
  shiny::callModule(mod_genomic_server, "genomic_ui_1")
  # Your application server logic
}



#' The application User-Interface
#'
#' @param request Internal parameter for `{shiny}`.
#'     DO NOT REMOVE.
#' @import shiny
#' @noRd
app_ui <- function(request) {
  tagList(
    # Leave this function for adding external resources
    golem_add_external_resources(),
    # Your application UI logic
    shinyUI(
      navbarPage(
        windowTitle = "Page",
        title = div(img(src = ".png", height = "30px"), "Toolbox"),
        theme = shinythemes::shinytheme("cerulean"),
        tabPanel("Toolbox", icon = icon("wrench"),
                 shinydashboard::dashboardPage(
                   skin = "black",
                   header = shinydashboard::dashboardHeader(title = "Toolbox", titleWidth = 300),
                   shinydashboard::dashboardSidebar(
                     width = 300 ,
                     shinydashboard::sidebarMenu(
                       shinydashboard::menuItem(
                         "Tools",
                         tabName = "tools_app",
                         icon = icon("wrench"),
                         shinydashboard::menuSubItem(
                           "Gene Expression/Signature/Pathways",
                           tabName = "gene_app",
                           icon = icon("chart-line")
                         ),
                         shinydashboard::menuSubItem(
                           "Genomic",
                           tabName = "genomic_app",
                           icon = icon("universal-access")
                         ),
                       )
                     )
                   )
                  ),
                   shinydashboard::dashboardBody(
                     shinydashboard::tabItems(
                       shinydashboard::tabItem("tools_app", mod_tools_path_ui("tools_path_ui_1")),
                       shinydashboard::tabItem("gene_app",mod_gene_expressions_sign_path_ui("gene_expression_sign_path_ui_1")),
                       shinydashboard::tabItem("genomic_app", mod_genomic_ui("genomic_ui_1"))
}




#' Add external Resources to the Application
#'
#' This function is internally used to add external
#' resources inside the Shiny application.
#'
#' @import shiny
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
#' @noRd
golem_add_external_resources <- function() {
  add_resource_path(
    "www",
    app_sys("app/www")
  )

  tags$head(
    favicon(),
    bundle_resources(
      path = app_sys("app/www"),
      app_title = "bftb"
    )
    # Add here other external resources
    # for example, you can add shinyalert::useShinyalert()
  )
}

And I get error such as:

Error: argument "body" is missing, with no default

And with more explanations on the error I get is here:

Error: argument "body" is missing, with no default

Backtrace:
  1. bftb::app_ui()
       at test-golem-recommended.R:2:2
 22. shinydashboard::dashboardPage(...)
 23. shinydashboard:::tagAssert(body, type = "div", class = "content-wrapper")

Solution

  • dashboardPage(header, sidebar, body) is missing its body parameter (in your above code dashboardBody isn't called in the right place - note the parenthesis).

    Please try the following:

    app_server <- function(input, output, session) {
      shiny::callModule(mod_tools_server, "tools_path_ui_1")
      shiny::callModule(mod_gene_expressions_sign_path_server, "gene_expression_sign_path_ui_1")
      shiny::callModule(mod_genomic_server, "genomic_ui_1")
      shiny::callModule(mod_epi_server, "epi_ui_1")
      shiny::callModule(mod_io_server, "io_ui_1")
      shiny::callModule(mod_pharm_server, "pharm_ui_1")
      shiny::callModule(mod_cell_server, "cell_ui_1")
      shiny::callModule(mod_mouse_server, "mouse_ui_1")
      shiny::callModule(mod_hemebase_server, "hemebase_ui_1")
      shiny::callModule(mod_multiomics_server, "multiomics_ui_1")
      shiny::callModule(mod_other_server, "other_ui_1")
      # Your application server logic
    }
    
    
    
    #' The application User-Interface
    #'
    #' @param request Internal parameter for `{shiny}`.
    #'     DO NOT REMOVE.
    #' @import shiny
    #' @noRd
    app_ui <- function(request) {
      tagList(
        # Leave this function for adding external resources
        golem_add_external_resources(),
        # Your application UI logic
        shinyUI(
          navbarPage(
            windowTitle = "BFTB Landing Page",
            title = div(img(src = "bftb_logo_v8_bare.png", height = "30px"), "AZ Oncology Bioinformatics Toolbox"),
            theme = shinythemes::shinytheme("cerulean"),
            tabPanel("Toolbox", icon = icon("wrench"),
                     shinydashboard::dashboardPage(
                       skin = "black",
                       header = shinydashboard::dashboardHeader(title = "AZ Oncology Bioinformatics Toolbox", titleWidth = 300),
                       shinydashboard::dashboardSidebar(
                         width = 300 ,
                         shinydashboard::sidebarMenu(
                           shinydashboard::menuItem(
                             "Tools",
                             tabName = "tools_app",
                             icon = icon("wrench"),
                             shinydashboard::menuSubItem(
                               "Gene Expression/Signature/Pathways",
                               tabName = "gene_app",
                               icon = icon("chart-line")
                             ),
                             shinydashboard::menuSubItem(
                               "Genomic",
                               tabName = "genomic_app",
                               icon = icon("universal-access")
                             ),
                             shinydashboard::menuSubItem(
                               "Epigenetics",
                               tabName = "epi_app",
                               icon = icon("chart-bar")
                             ),
                             shinydashboard::menuSubItem(
                               "Immune-oncology",
                               tabName = "io_app",
                               icon = icon("heartbeat")
                             ),
                             shinydashboard::menuSubItem(
                               "Pharmacology",
                               tabName = "pharm_app",
                               icon = icon("plus-square")
                             ),
                             shinydashboard::menuSubItem(
                               "Cell line Selection",
                               tabName = "cell_app",
                               icon = icon("sellcast")
                             ),
                             shinydashboard::menuSubItem("Mouse",
                                                         tabName = "mouse_app",
                                                         icon = icon("paw")),
                             shinydashboard::menuSubItem(
                               "Haem Oncology",
                               tabName = "hemebase_app",
                               icon = icon("h-square")
                             ),
                             shinydashboard::menuSubItem("Multiomics",
                                                         tabName = "multiomics_app",
                                                         icon = icon("list")),
                             shinydashboard::menuSubItem(
                               "Other",
                               tabName = "other_app",
                               icon = icon("option-horizontal", lib = "glyphicon"))
                           )
                         )
                       ),
                       shinydashboard::dashboardBody(
                         shinydashboard::tabItems(
                           shinydashboard::tabItem("tools_app", mod_tools_path_ui("tools_path_ui_1")),
                           shinydashboard::tabItem("gene_app",mod_gene_expressions_sign_path_ui("gene_expression_sign_path_ui_1")),
                           shinydashboard::tabItem("genomic_app", mod_genomic_ui("genomic_ui_1")),
                           shinydashboard::tabItem("epi_app", mod_epi_ui("epi_ui_1")),
                           shinydashboard::tabItem("io_app", mod_io_ui("io_ui_1")),
                           shinydashboard::tabItem("pharm_app", mod_pharm_ui("pharm_ui_1")),
                           shinydashboard::tabItem("cell_app", mod_cell_ui("cell_ui_1")),
                           shinydashboard::tabItem("mouse_app", mod_mouse_ui("mouse_ui_1")),
                           shinydashboard::tabItem("hemebase_app", mod_hemebase_ui("hemebase_ui_1")),
                           shinydashboard::tabItem("multiomics_app", mod_multiomics_ui("multiomics_ui_1")),
                           shinydashboard::tabItem("other_app", mod_other_ui("other_ui_1"))))
                     ))
          )))
    }
    
    
    
    
    #' Add external Resources to the Application
    #'
    #' This function is internally used to add external
    #' resources inside the Shiny application.
    #'
    #' @import shiny
    #' @importFrom golem add_resource_path activate_js favicon bundle_resources
    #' @noRd
    golem_add_external_resources <- function() {
      add_resource_path(
        "www",
        app_sys("app/www")
      )
      
      tags$head(
        favicon(),
        bundle_resources(
          path = app_sys("app/www"),
          app_title = "bftb"
        )
        # Add here other external resources
        # for example, you can add shinyalert::useShinyalert()
      )
    }