Hi,

I have written a function "harvest" and I would like to run the function for
each value in a vector c(1:1000). The function returns 4 list objects
(obj_1, obj_3, obj_3, obj_4) using the following code at the end of the
function: return(list(obj_1 = obj_1, obj_2 = obj_2, obj_3 = obj_3, obj_4 =
obj_4)).
Since I am connecting with the web in the function and the connection
sometimes fails causing errors to occur, I invoke the function as follows:

for(i in 1:1000){
  result <- try(harvest(i));
  if(class(result) == "try-error") next;
  }

Everything works well accept for the fact that "result" only stores obj_1, 
obj_2, obj_3,  obj_4 for the last i in the loop. How do I store obj_1, 
obj_2, obj_3,  obj_4 for the first i in the first 4 elements of result, the
objects for the second i in the next 4 elements, etc?

Thank you very much.  





--
View this message in context: 
http://r.789695.n4.nabble.com/Accumulate-objects-in-list-after-try-tp4650927.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to