Re: [R] try-error within for loop

2010-08-06 Thread Olga Lyashevska
Wu Gong wrote: > So, try() inside loop should work. Like > > for () { > if (class(try(...,silent=T))=="try-error") result[[i]] <- NA > ... > } Thanks a lot, it worked for me! Cheers Olga __ R-help@r-project.org mailing list https://stat.ethz

Re: [R] try-error within for loop

2010-08-05 Thread Wu Gong
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 t

[R] try-error within for loop

2010-08-05 Thread Olga Lyashevska
Dear all, I run a loop wrapped in try(), and for each of the rows where "try-error" is true I want to fill that row with NA (at the moment it is omitted). So I would expect to get a dataframe with 1000 rows some of which would be empty, but instead I get a dataframe with 995 rows. In this case mi