コマンドラインでRスクリプトを実行する場合(実際にはVBAでの呼び出しから実行します)、エラー/警告メッセージをtxtファイルに出力するにはどうすればよいですか?
			
			21695 次
		
2 に答える
            39        
        
		
sink()メッセージや警告をファイルに転送するために使用できます。秘訣は引数を設定することtype="message"です:
以下のヘルプから適応した例を次に示します?sink。
setwd(tempdir())
## capture messages and errors to a file.
zz <- file("all.Rout", open="wt")
sink(zz, type="message")
try(log("a"))
## reset message sink and close the file connection
sink(type="message")
close(zz)
## Display the log file
readLines("all.Rout")
[1] "Error in log(\"a\") : Non-numeric argument to mathematical function"
    于 2012-07-26T10:11:29.733   に答える
    
    
            21        
        
		
ログファイルとの接続を閉じるには、のsink(type="message")代わりにを使用する必要がsink()ありますclose(zz)。
于 2014-06-24T16:22:02.960   に答える