I'd like to create warning/error log for the R script.
Please see below example:
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)
I was expecting that it will enlist all warnings:
Warning messages:
1: In log(i - 50) : NaNs produced
2: In log(i - 50) : NaNs produced
3: In log(i - 50) : NaNs produced
However for the loop i in 1:30 there is only one line in the all.rout file:
There were 30 warnings (use warnings() to see them)
Any idea how to fix it?
I have created the code based on another topic:
Output error/warning log (txt file) when running R script under command line