Home > OS >  Shiny app using modules does not return a shiny.appobj object when deployed local
Shiny app using modules does not return a shiny.appobj object when deployed local

Time:03-30

Im trying to build a shiny app using modules, however, when I try to run the app localy I get the error message: "Error inin func(fname, ...) : app.R did not return a shiny.appobj object."

When I omit the modules and do everything in one single app.R file, it works fine.

The folder structure is as follows:

"Project_Folder"

  1. app.R
  2. "R" Folder -> "Form_UI.R", "Data_Browser_Server.R"
  3. "Testdata.feather"
library(shiny)
library(shinydashboard)
library(tidyverse)
library(DT)


df_Browser_data <- feather::read_feather("Testdata.feather")

Datenbericht_App <- function(){
    ui <- dashboardPage(
        title = "Prototype",
        dashboardHeader(title = "Browser prototype", titleWidth = 350),
        skin = "red",
        dashboardSidebar(
            width = 350,
            disable = FALSE,
            sidebarMenu(
                id = "tabs",
                menuItem(
                    text = "Data Browser",
                    tabName = "Data_Browser"
                ),
                menuItem(
                    text = "Preview",
                    tabName = "Preview_Window"
                )
            )
        ),
        mainPanel(
            tabItems(
                tabItem(tabName = "Data_Browser",
                        fluidPage(
                            Form_UI("Overview"),
                            dataTableOutput("Browser_Table")
                        )
                ),
                tabItem(tabName = "Preview_Window",
                        fluidPage(
                        )
                )
            )
        )
    )
    
    server <- function(input, output, session) {
        output$Browser_Table <- renderDataTable(Data_Browser_Server("Overview"))
    }
    
    shinyApp(ui, server)
}


CodePudding user response:

You return the function Datenbericht_App. The shinyApp function returns a shiny app object inside Datenbericht_App but it isn't called. You could run Datenbericht_App() on the last line of your script to return a shiny app object.

A simplified example:

library(shiny)

myWrapper <- function(){
  ui <- fluidPage(
    h1("This is just a test")
  )
  server <- function(input, output, session) {}
  shinyApp(ui, server)
}

myWrapper()
  • Related