[R] try-error within for loop

Wu Gong wg2f at mtmail.mtsu.edu
Fri Aug 6 01:38:17 CEST 2010


Assigning the value directly to result[i] would give a null to result. Like
that:

result[[i]]<-taxondiveO(abd,taxa)
result[[i]]<-as.data.frame(result[[i]])[1,]

In fact your code's result should have null elements in it. You lost your
nulls through do.call process.

I can't find a way to assign the value of error into a object. So, try()
inside loop should work. Like

for (....) {
if (class(try(...,silent=T))=="try-error") result[[i]] <- NA
...
}



-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/try-error-within-for-loop-tp2315550p2315738.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list