user7353167
user7353167

Reputation:

object 'output' not found

I created a Shinydashboard and want to produce an outputTable, but i get the error object "output" not found. I have absolutely no clue why this happens. In the server function i have an "output", and the data stream should also work. Can you help me? Here is the code:

### Notwendige Pakete laden.

rm(list = ls())

if (!require('dplyr')) install.packages('dplyr'); library('dplyr')
if (!require('shiny')) install.packages('shiny'); library('shiny')
if (!require('shinydashboard')) install.packages('shinydashboard'); library('shinydashboard')
if (!require('car')) install.packages('car'); library('car')
if (!require('Hmisc')) install.packages('Hmisc'); library('Hmisc')
if (!require('ggplot2')) install.packages('ggplot2'); library('ggplot2')
if (!require('foreign')) install.packages('foreign'); library('foreign')
if (!require('tidyr')) install.packages('tidyr'); library('tidyr')
if (!require('highcharter')) install.packages('highcharter'); library('highcharter')
if (!require('DT')) install.packages('DT'); library('DT')

data <- readRDS("C:/Users/langma/Desktop/Mini/MP_MINI_Aftersales_Export.rds")
datalabels <- readRDS("C:/Users/langma/Desktop/Mini/var.labels.rds")

## app.R ##


ui <- dashboardPage(
    dashboardHeader(title = "Mini Dashboard"),
    dashboardSidebar(includeCSS("www/style.css"),
        sidebarMenu(
            h3("Filtereinstellungen"),
            selectizeInput("country", "Land", choices = data$v_2, selected = data$v_2, multiple = TRUE),
            selectizeInput("modell", "Automodell", choices = data$v_3, selected = data$v_3, multiple = TRUE),
            selectizeInput("sex", "Geschlecht", choices = data$v_2, selected = data$v_2, multiple = TRUE),
            selectizeInput("money", "Finanzierung", choices = data$v_18, selected = data$v_18, multiple = TRUE)
        )
    ),
    dashboardBody(
        fluidRow(
            tabBox(width = 6,
                title = "Touchpoints",
                # The id lets us use input$tabset1 on the server to find the current tab
                id = "tabset1", height = "500px",
                tabPanel("Tab1", tableOutput("anzahl")),
                tabPanel("Tab2", "Kaufort"),
                tabPanel("Tab3", "Privatkauf Anbahnung")
            ),
            tabBox(width = 6,
                   title = "Automotive", 
                   # The id lets us use input$tabset1 on the server to find the current tab
                   id = "tabset2", height = "500px",
                   tabPanel("Tab4", "Neu-/Gebrauchtwagen"),
                   tabPanel("Tab5", "Kaufort"),
                   tabPanel("Tab6", "Privatkauf Anbahnung")
            )
    )
))

server <- function(input, output, session) { }
        df <- reactive({
            filtereddata <- data %>%
                filter(v_2 %in% input$country)
        })

        output$anzahl <- renderTable({
            df()
        })


shinyApp(ui, server)

Upvotes: 0

Views: 3026

Answers (1)

phalteman
phalteman

Reputation: 3542

It's helpful to create reproducible examples so that those attempting to answer your question can test their responses.

That said, the clue is that your app can't find the output object, which means it's not in the reactive environment where everything in a shinyapp needs to be. The only way that's possible is if your output table is not actually inside the server function. Edit the brackets to something like this and see where that gets you:

server <- function(input, output, session) {
        df <- reactive({
            filtereddata <- data %>%
                filter(v_2 %in% input$country)
        })

        output$anzahl <- renderTable({
            df()
        })
}

Upvotes: 1

Related Questions