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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.