[R] ignore error getting next result

David Winsemius dwinsemius at comcast.net
Tue Mar 27 19:40:39 CEST 2012

On Mar 27, 2012, at 12:56 PM, C Lin wrote:

> Dear All,
> How do I ignore an error and still getting result of next iteration.
> I am trying to do wilcox.test on a loop, when the test fail, I would  
> like to continue doing the next iteration and getting the p-value.
> I tried to do tryCatch or try but I cannot retrieve the p-value if  
> the test is not fail.
> sample code:
> test2=list(numeric(0),c(10,20));
> test1=list(c(1),c(1,2,3,4));
> for (i in 1:2){
> wtest=wilcox.test(test1[[i]],test2[[i]])
> }
> i=1 will fail, I want to ignore this and get the pvalue for i=2.

Please read the FAQ entry And you would be advise to read through the  
rest of the FAQ as well.


> Thanks,
> Lin 		 	   		
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at 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.

David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list