R闪亮的widgetFunc()函数在eventReactive中出现警告信息(警告1),并在renderDataTable中出现另一个警告信息(警告2)。

6
我正在编写一个闪亮的应用程序,之前一切都运行得很好,但突然出现了两个警告消息。我回到之前可以正常运行的副本,但它们现在也显示相同的错误消息,所以我真的很困惑。我的代码仍然可以运行,并在我的闪亮仪表板的结果选项卡上显示准确的结果,但我想追踪警告消息。我进行了调试,使用rendDataTable后第一个警告消失了,当我单击我的仪表板上的选项卡时,第二个警告出现。数据是一个n X 10的数据框,包含数字和字符。非常感谢任何帮助。如果我可以提供更多信息,请让我知道。

这里是1:

Warning in widgetFunc() :
  renderDataTable ignores ... arguments when expr yields a datatable object; see ?renderDataTable
Warning: Error in cat: argument 1 (type 'environment') cannot be handled by 'cat'
Stack trace (innermost first):
    74: cat
    73: eval
    72: eval
    71: withVisible
    70: evalVis
    69: utils::capture.output
    68: paste
    67: output$ntext1
     1: shiny::runApp

这里是2:
Warning in widgetFunc() :
  renderDataTable ignores ... arguments when expr yields a datatable object; see ?renderDataTable

tran_cd=c('I','E','R')
data_source_cd=c('1','2','3','4')
library(shiny)
library(shinydashboard)
library(xlsx)
if (!require("DT")) install.packages('DT')
sessionInfo()
library(DT)
ui <- dashboardPage(
  dashboardHeader(title = "ARC"),
  dashboardSidebar(sidebarMenu(
    menuItem("Settings", tabName = "settings", icon = icon("th")),
    menuItem("Results Table", tabName = "ResultsTable", icon = icon("ResultsTable")))),
  dashboardBody(
    tabItems(tabName = "ResultsTable",
              fluidPage(  
                headerPanel(
                  h1("Anomaly List", align="center",  style = "font-family: 'Verdana';font-weight: 800; line-height: 1.1;   color: #151515;")),
                # fluidRow(
                #     column(8, DT::dataTableOutput("table",width = "100%"),offset = 2)))),
                #                 # Create a new Row in the UI for selectInputs
                fluidRow(

                  column(4,
                         selectInput("sour",
                                     "Source Type:",
                                     c("All",
                                       unique(as.character(data_source_cd))))
                  ),
                  column(4,
                         selectInput("sour1",
                                     "Source Type:",
                                     c("All",
                                       unique(as.character(data_source_cd))))
                  ),
                  column(4,
                         selectInput("tran",
                                     "Transaction Type:",
                                     c("All",
                                       unique(as.character(tran_cd)))))),
                # Create a new row for the table.
                fluidRow(column(8, DT::dataTableOutput("table",width = "100%"),offset = 2))))
)))




library(shiny)
library(chron)
library(forecast)
library(ggplot2)
#names(iris) = gsub("\\.", "", names(iris))
setwd("C:/Users/Name/Documents/Projects/TrendAnalysis/Data")
source("C:/Users/Documents/Projects/TrendAnalysis/Rcode/App-1/MonitoringIngestion.R")
df=read.csv('list.csv',header=TRUE, stringsAsFactors = FALSE)
df=unique(df[,1:3])
dfrn=df[,2];
rownames(df)=make.names(dfrn, unique=TRUE)
shinyServer(function(input, output, session) {
  rv <- reactiveValues()
  rv$data <- NULL

  ntext1 <- eventReactive(input$gobutton,{
    if (input$dateRange[2]<input$dateRange[1]){print("You selected the date range option;however, the end date entered occurs before the starting date")}
    else{
      output$ntext1 <- renderText({print("Analysis Complete...Data Loading...")});
      observe({    ## will 'observe' the button press
        if(input$gobutton){ 
          print("here")  ## for debugging
          Singledate=input$date;
          Daterange=input$dateRange;
          Alldata=input$checkbox;
          SourceSelect=input$checkGroup1;
          TranSelect=input$checkGroup2;
          AirlineSelect=input$x3_rows_selected;
          Mag_level=input$slider1;
          rv$data <- MonitoringDDSIngestion(Alldata,Singledate,Daterange,SourceSelect,TranSelect,AirlineSelect,Mag_level)   ## store the data in the reactive value
        }
      })
    }
  }) 

  output$table <- DT::renderDataTable(DT::datatable({
     data <- rv$data
    if (input$sour != "All") {
      data <- data[data[,1] == input$sour,]
    }else{data}
     if (input$sour1 != "All") {
       data <-data[data[,2] == input$sour1,]
     }else{data}

     if (input$tran != "All") {
       data <-data[data[,3] == input$tran,]
     }else{data}

  }), filter='top')
})


MonitoringIngestion2 <-function(All,date1,date2, source_cd,tran_cd,airline_list,mag_level) {
    print(All); print(date1); print(date2); print(source_cd);print(tran_cd);print(airline_list);print(mag_level)
    setwd("C:Documents/Projects//Data")
    data = read.csv("November2015_December2015.csv",header=TRUE,sep=",",colClasses="factor")
  }
data  

2
刚刚运行了你的代码,如果你能提供MonitoringIngestion.R和list.csv文件,那就太棒了,这样我就可以玩弄它了,如果你没意见的话。 - InfiniteFlash
1
你最近有升级过软件包吗? - Xiongbing Jin
1
那么这很可能是由于软件包更新引起的软件包不兼容性,你可能无法做任何事情(除非你想降级,或者你想等待软件包作者解决)。 - Xiongbing Jin
@warmoverflow,这很有道理,因为我所有的其他脚本版本也都不起作用,所以很难相信是代码的问题。你能否从我在脚本顶部加载的包中得出任何想法呢?此外,当我升级某些包时,与之相关的其他包也会被更新。有没有办法让我追踪到它们的变化?我没有降级的问题。 - Tracy
2
警告信息来自于 DT,但由于 DT 已经有一段时间没有更新了(仍然是 0.1 版本),我怀疑这是由于较新版本的 Shiny(与 DT 交互)或者您安装了 GitHub 版本的 DT 所导致的。但如果您的结果是正确的,那么我建议您忽略这个警告。 - Xiongbing Jin
显示剩余3条评论
1个回答

11
您之所以收到此错误信息,是因为您返回了一个DT::datatable表格,并且还指定了filter='top'作为DT::renderDataTable的一个参数。正如该消息所示,由于您返回了一个DT::datatable,因此将忽略该...参数。这是因为...参数旨在通过DT:datatable构造函数传递。
可以将filter='top'移动到DT::datatable构造函数内部,或者返回data.frame,当DT::renderDataTable构造使用指定的data.frame时,filter='top'将会被应用。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接