send R diagnostic messages to stdout instead stderr

前端 未结 4 1572
醉梦人生
醉梦人生 2020-12-31 23:13

Looking for an options which let me to redirect R diagnostic messages (produces by message()) to stdout, not stderr as it is by defaul

4条回答
  •  耶瑟儿~
    2020-12-31 23:46

    Using sink. Here's a modification of your code:

    sink(stdout(), type = "message") # sink messages to stdout
    print("using print")
    cat("using cat\n")
    message("using message")
    warning("using warning")
    sink(NULL, type="message") # close the sink
    warning("after ending sink") # this will be the only thing in your err file
    q("no")
    

提交回复
热议问题