R Shiny App Error: "Warning: Error in plot.window: need finite 'xlim' values"

R Shiny App Error: "Warning: Error in plot.window: need finite 'xlim' values"

我对 Shiny 还很陌生,但我正在尝试创建一个应用程序,允许用户输入名字、姓氏或社会安全号码(或全部三个或两个,等等)。 ) 然后它将 ping sql 查询和 return 正确的结果。然而,我 运行 遇到以下错误。

Warning in min(x) : no non-missing arguments to min; returning Inf
Warning in max(x) : no non-missing arguments to max; returning -Inf
Warning in min(x) : no non-missing arguments to min; returning Inf
Warning in max(x) : no non-missing arguments to max; returning -Inf
Warning: Error in plot.window: need finite 'xlim' values
  [No stack trace available]

下面是我的代码:

rm(list=ls())
library(shiny)
library(RODBC)
ui <- bootstrapPage(
  
  textInput(inputId = "First_Name",
              label = "First_Name",
              value = "",
              width = NULL,
              placeholder = "Enter Client's First Name"),
  textInput(inputId = "SSN",
            label = "SSN",
            value = "",
            width = NULL,
            placeholder = "Enter Client's SSN"),
  textInput(inputId = "Last_Name",
            label = "Last_Name",
            value = "",
            width = NULL,
            placeholder = "Enter Client's Last Name"),
  
  plotOutput(outputId = "main_plot", height = "300px")
  
)
server <- function(input, output) {
  
  BDW <- odbcConnect("BDW", uid="", pwd="", believeNRows = FALSE)
  
  table1 <- reactive({sqlQuery(BDW,paste("
                      SELECT name as 'Name:',ssn as 'SSN', a.address + ', ' + a.city + ', ' + a.state + ', ' + a.zip as 'Address:'
  FROM [RM].[dbo].[CustomerMaster] a
    LEFT JOIN [UVC].[dbo].[UVCWeb_CustomerFlat]b ON a.number = b.RMNumber
  WHERE
  name like '%",input$First_Name,"%'
  and name like '%",input$Last_Name,"%'
  and ssn like '%",input$SSN,"%'
  and bdw_CurrentIndicator = 1"))})
  
  output$main_plot <- renderPlot({
    
    plot(table1()$Name, table1()$SSN, table1()$Address)
    
  })
}
shinyApp(ui, server)

涉及的数据非常简单,只有客户姓名、SSN 和地址。非常感谢所有预先提供的帮助。谢谢!

您可以“绘制”您的 table,例如library(datatable)。您将使用以下方式编辑您的代码:

 dataTableOutput("mytable") 

在你的ui和

output$mytable = DT::renderDataTable({ your data.table }) 

在您的服务器中。 看这里:shiny.rstudio.com/articles/datatables.htm