R批处理模式:如何在控制台屏幕上查看R的输出/错误? [英] R batch mode: How to see output/error of R on console screen?

查看:70
本文介绍了R批处理模式:如何在控制台屏幕上查看R的输出/错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以批处理模式运行R代码时,我需要R代码中的消息/错误/日志以显示在控制台屏幕上,而不是.Rout文件中.

While running R code in batch mode i need messages/errors/logs from R code to be shown on console screen instead of .Rout file.

我尝试了所有来自堆栈溢出的帖子(链接复制到下面),并且没有一个显示我想要的输出.

I tried all the posts(links copied below) from stack overflow and none of them are showing me desired output.

  1. 在批处理模式下运行到屏幕打印?
  2. 无法通过Windows服务器中的蝙蝠文件运行R脚本
  3. r-cmd-batch-output-in-terminal
  1. running-r-in-batch-mode-print-to-screen?
  2. unable-to-run-r-script-through-bat-files-in-windows-server
  3. r-cmd-batch-output-in-terminal

批处理代码:我也尝试过使用tty0.

batch code: i tried with tty0 as well.

"C:\Program Files\R\R-3.2.2\bin\R.exe" CMD BATCH --slave "Test.R" /dev/tty

Test.R代码

print(1:10)

如果有人可以帮助我显示正确的代码编写方式以在控制台屏幕上显示输出的话,这将非常有帮助.而且我正在Windows环境下工作.

It will be very helpful if some has can help me in showing the correct way of writing the code to show the output in console screen.And i am working on windows environment.

非常感谢您的帮助.

推荐答案

您可以使用stdoutstderr重定向要打印的日志.做到这一点的示例方法是:

You can redirect the log that you want to print using stdout or stderr. Sample way to do that will be:

write("Hello World!!", stderr())

在这里,我将重定向"Hello World !!".到stderr.如果在上面的代码片段中使用stdout()而不是stderr(),则理想情况下,它应该将日志写入stdout.但是,尝试写入stdout时,我遇到了一些问题.

Here I am redirecting "Hello World!!" to stderr. If you use stdout() instead of stderr() in code snippet above then ideally it should write log to stdout. However I have seen some issues when trying to write into stdout.

这篇关于R批处理模式:如何在控制台屏幕上查看R的输出/错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆