首页 文章

你怎么能总是抑制R中的消息?

提问于
浏览
5

我在这里讨论的最常见的地方是've seen messages used in R is in the starting of a package. Suppressing one function',如下所述:Disable Messages Upon Loading Package in R . 通过在 supressMesssages 函数调用中嵌入 {} ,也可以抑制多行消息生成函数调用 . 但是,如果你有一个完整的脚本,在这里和那里发生消息,无论如何都要完全禁用它们?我正在寻找像选项(warn = -1)但是对于消息的东西 . 请注意 sink 并不是我想要的,因为它重定向所有输出...我想保持 print 的输出,但不保持 message 的输出 .

1 回答

  • 7

    在sink中使用type参数

    # Open a file to send messages to
    zz <- file("messages.Rout", open = "wt")
    # Divert messages to that file
    sink(zz, type = "message")
    message("not gonna show up in console")
    

相关问题