警告:过滤器renderDataTable中的错误

时间:2018-08-01 01:09:30

标签: r shiny

我正在尝试在R 中创建搜索工具,如下代码 但是,一旦运行,它就会弹出并显示错误消息

Warning: Error in filter: object 'Category' not found
  [No stack trace available]

我是R闪亮的新手。任何建议将不胜感激 谢谢堆

library(shiny)
library(DT)

# Data frame
df <- read.csv("Z:/Valuations Risk & Quality/July 2018- Commercial Panel Look up Tool - R/CSV/PanelFirmList.csv", header=TRUE)
df$Postcode<- as.character(df$Postcode)
df <- df[,c(4,3,6,9,10,11,12,13,14)]

# Define UI for application that draws a histogram
ui <- fluidPage(

  # Application title
  titlePanel("NAB Panel lookup tool"),

  # Postcode textbox 
  sidebarLayout(
    sidebarPanel(
      textInput("postcode",
                "Postcode"
      ),
      selectInput("category",
                  "Category",
                  choices = unique(df$Category)
      ),
      selectInput("panel",
                  "Panel Type",
                  choices = unique(df$Panel_Type)
      ),
      selectInput("value",
                  "Value Range",
                  choices = unique(df$Value_Range)
      )
    ),
    # Show filtered data frame
    mainPanel(
      DT::dataTableOutput("table")
    )
  )
)

# Define server logic required to produce table
server <- function(input, output, session) {

    output$table <- DT::renderDataTable({
    df %>% 
      filter ((Postcode == input$postcode) & (Category == input$category) & (Panel_Type == input$panel) & (Value_Range == input$value)) %>% 
      select(c(Region, Valifirm, Email, Phone))
  })
}
# Run the application 
shinyApp(ui = ui, server = server) 

0 个答案:

没有答案