【问题标题】:R shiny widgetFunc() warning messages with eventReactive(warning 1) and renderDataTable (warning 2)R闪亮的widgetFunc()带有eventReactive(警告1)和renderDataTable(警告2)的警告消息
【发布时间】:2016-07-05 22:09:43
【问题描述】:

我正在编写一个闪亮的应用程序,它运行良好,突然间我收到两条警告消息。我已经回到以前运行良好的副本,它们现在显示相同的错误消息,所以我真的很困惑。我的代码仍在运行并在我闪亮的仪表板的结果选项卡上显示准确的结果,但我想追踪警告信息。我进行了调试,第一个警告随着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  

【问题讨论】:

  • 刚刚运行了你的代码,如果你提供了 MonitoringIngestion.R 和 list.csv 文件,我可以玩弄它,如果你没问题的话,那会很棒。
  • @InfiniteFlashChess 感谢您的回复。我用更简单的方法替换了原始的 MonitoringIngestion 函数,以查看它是否是该代码(见上文)。它只是加载一个数据文件,我仍然收到相同的警告 (1)。数据文件是具有数字和字符列的 nx7 数据框。奇怪的是我有不同版本的服务器、用户界面和监控,因为我保存它们,所以我可以随时返回,即使是运行良好的旧版本也有相同的警告。我无法准确追踪它的生产地点。很难在闪亮中调试。
  • 你最近有没有升级你的包?
  • 那么这很可能是包更新导致包之间的不兼容,你可能无能为力(除非你想降级,或者你想等待包作者解决它)
  • 警告信息来自DT,但由于DT有一段时间没有更新(仍然是0.1版本),我怀疑它是由较新版本的Shiny引起的(它交互使用 DT),或者您可能已经安装了 DT 的 github 版本。但如果你的结果是正确的,我会说忽略警告。

标签: r shiny


【解决方案1】:

您收到此错误是因为您返回了 DT::datatable AND 您还将 filter='top' 指定为 ... 参数之一给 DT::renderDataTable。由于消息试图告诉您...,参数被忽略,因为您返回DT::datatable。这是因为 ... 参数旨在传递给 DT:datatable 构造函数。

DT::datatable 构造函数中移动filter='top' 或返回data.frame,当DT::renderDataTable 使用您指定的data.frame 构造DT::datatable 时,将使用filter='top

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-30
    • 2022-08-20
    • 2017-08-31
    • 2015-05-15
    • 1970-01-01
    • 2010-09-18
    • 2021-01-19
    • 1970-01-01
    相关资源
    最近更新 更多