How can I redirect R warning messages to STDOUT?

故事扮演 提交于 2019-11-30 12:50:29

Look at the help page for sink():

‘sink’ diverts R output to a connection. If ‘file’ is a character string, a file connection with that name will be established for the duration of the diversion.

Normal R output (to connection ‘stdout’) is diverted by the default ‘type = "output"’. Only prompts and (most) messages continue to appear on the console. Messages sent to ‘stderr()’ (including those from ‘message’, ‘warning’ and ‘stop’) can be diverted by ‘sink(type = "message")’ (see below).

@Dirk already provided the answer, but I would just add that you can use stdout() to get a connection to the STDOUT. You can use this in any output function to direct output there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!