Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行R脚本时创建警告日志文件_R_Warnings_Sink - Fatal编程技术网

运行R脚本时创建警告日志文件

运行R脚本时创建警告日志文件,r,warnings,sink,R,Warnings,Sink,我想为R脚本创建警告/错误日志。 请参见以下示例: setwd(tempdir()) zz <- file("all.Rout", open="wt") sink(zz, type="message") for (i in 1:30){ log(i-50) } sink(type="message") close(zz) setwd(tempdir()) zz尝试选项(warn=1) 从?选项: 'warn': se

我想为R脚本创建警告/错误日志。
请参见以下示例:

setwd(tempdir())
zz <- file("all.Rout", open="wt")
    sink(zz, type="message")
    for (i in 1:30){
           log(i-50)
         }
    sink(type="message")
    close(zz)
setwd(tempdir())
zz尝试
选项(warn=1)

?选项

'warn': sets the handling of warning messages.  If 'warn' is
      negative all warnings are ignored.  If 'warn' is zero (the
      default) warnings are stored until the top-level function
      returns.  If 10 or fewer warnings were signalled they will be
      printed otherwise a message saying how many were signalled.
      An object called 'last.warning' is created and can be printed
      through the function 'warnings'.  If 'warn' is one, warnings
      are printed as they occur.  If 'warn' is two or larger all
      warnings are turned into errors.

完美的谢谢:)