Hello, all.
There is a problem to get an output of warnings() function to sink in a
file specified.
There are to files
1. File "test" with content:
source("test_foo",local=T)
2. and file "test_foo" with content:
options(warn = 1)
sink("c:/temp/foo.txt",append=F)
warning("Foo warning")
warnings()
sink()
3. If I run R as
"c:\Program Files\R\rw2011\bin\R.exe" --no-save < test > out.txt
the file "c:/temp/foo.txt" will contain nothing.
But I'd like it should contain the warning message "Foo warning".
Is the behavior a bug of R or there is another way to get it working.
Thanks in advance, Alex
Arkady Sherman wrote:> Hello, all. > There is a problem to get an output of warnings() function to sink in a > file specified. > There are to files > > 1. File "test" with content: > > source("test_foo",local=T) > > 2. and file "test_foo" with content: > > options(warn = 1) > sink("c:/temp/foo.txt",append=F) > warning("Foo warning") > warnings() > sink() > > 3. If I run R as > > "c:\Program Files\R\rw2011\bin\R.exe" --no-save < test > out.txt > > the file "c:/temp/foo.txt" will contain nothing. > But I'd like it should contain the warning message "Foo warning". > Is the behavior a bug of R or there is another way to get it working.See ?sink how to handle messages such as warnings. Uwe Ligges> Thanks in advance, Alex > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Sun, 11 Sep 2005, Arkady Sherman wrote:> > "c:\Program Files\R\rw2011\bin\R.exe" --no-save < test > out.txt > > the file "c:/temp/foo.txt" will contain nothing. > But I'd like it should contain the warning message "Foo warning". > Is the behavior a bug of R or there is another way to get it working.The help page for sink() documents the behaviour you are seeing, so it isn't a bug. The help page also describes how to do what you want, and even gives an example. -thomas