Suppress warning message in R console of shiny

后端 未结 3 1295
慢半拍i
慢半拍i 2021-01-02 11:02

We developed a shiny application. It was showing some warning messages, we never bothered it, because the application is working fine. But, we can\'t distribute the applicat

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 11:35

    Wrapping suppressWarnings around your code should work. See ?suppressWarnings. You need to do something like:

    atest <- function(n) {warning("a warning"); return(n+1)}
    atest(1)
    #[1] 2
    #Warning message:
    #In atest(2) : a warning
    
    suppressWarnings(atest(1))
    #[1] 2
    

    But I guess that the better solution is to actually deal with the warning and not just ignore it.

提交回复
热议问题