【问题标题】:R - Storing tryCatch Shiny warnings with read_excelR - 使用 read_excel 存储 tryCatch Shiny 警告
【发布时间】:2020-08-04 15:18:01
【问题描述】:

在我的 Shiny 应用程序中,我正在使用 read_excel 读取 Excel 文件。如果在上传过程中出现警告,我需要捕获列表中的所有警告,以便我可以进一步处理列表。但是,当前使用 tryCatch 的方法不起作用。

这是我的代码(在 Shiny 服务器模块中):

data <- reactive({(
    req(input$file1)
    inFile <- input$file1
    browser()
    data <- tryCatch(read_excel(inFile$datapath, 1), 
                 warning <- function(war){
                   message(war)
                 })    
})

非常感谢!

【问题讨论】:

标签: r shiny try-catch


【解决方案1】:

我做了以下事情: 创建了一个新对象 warn 并将警告存储在对象中,然后我正在使用该对象

warn <- tryCatch(read_excel(inFile$datapath, 1), 
                 warning = function(war){
                  war
                 })

【讨论】:

    猜你喜欢
    • 2016-06-17
    • 2021-10-25
    • 2020-08-10
    • 2017-02-25
    • 1970-01-01
    • 2019-12-31
    • 2015-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多