Dear listers,
Hi .
I googled before I ask this question in case to avoid violating the
"list law". The question was proposed by somebody else but nobody
gives a proper solution.
How to ignore errors in a R loop? I have a R source file ,namely,
test.r.
I ran a loop in a command line
> for(i in 1 : 100 ) {source("test.r",echo =T ) }
and I found that when test.r have some error the loop will stop, but
test.r is just stochastically wrong,i.e., sometimes it works well if
no bad values return.
I want to know how to ignore such errors and let the loop continue.
thanks in advance.
_______________________
Jiang Peng, Ph.D. Candidate
Department of Mathematics &
Antai college of Economics and Management
Shanghai Jiao Tong University
Address: Room 431, #3 Building, Xuhui Campus
E-mail: jp021 at sjtu.edu.cn
jp021 at 126.com
MSN: jp021 at hotmail.com
iChat: mathfrog at mac.com
Mobile: +86-138 168 780 95
how to ignore errors
2 messages · Jiang Peng, Bernardo Rangel Tura
On Mon, 2008-12-01 at 16:17 +0800, Jiang Peng wrote:
Dear listers, Hi . I googled before I ask this question in case to avoid violating the "list law". The question was proposed by somebody else but nobody gives a proper solution. How to ignore errors in a R loop? I have a R source file ,namely, test.r. I ran a loop in a command line
> for(i in 1 : 100 ) {source("test.r",echo =T ) }
and I found that when test.r have some error the loop will stop, but test.r is just stochastically wrong,i.e., sometimes it works well if no bad values return. I want to know how to ignore such errors and let the loop continue. thanks in advance.
_______________________
Jiang Peng,
The default solution is using try command, something like this
for(i in 1 : 100 ) {
try(source("test.r",echo =T ))
}
Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil