我创建了一个Shinydashboard并希望生成一个outputTable,但是我得到了错误对象"输出"未找到。我完全不知道为什么会这样。在服务器功能中,我有一个"输出",数据流也应该有效。你能帮助我吗?这是代码:
### 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)
答案 0 :(得分:0)
创建reproducible examples很有帮助,以便那些尝试回答您问题的人可以测试他们的回答。
那就是说,线索是你的应用程序无法找到输出对象,这意味着它不在反应环境中,而shinyapp中的所有东西都需要。唯一可行的方法是输出表实际上不在服务器功能中。将括号编辑为类似的内容并查看它的位置:
server <- function(input, output, session) {
df <- reactive({
filtereddata <- data %>%
filter(v_2 %in% input$country)
})
output$anzahl <- renderTable({
df()
})
}