Re: [R] Accumulate objects in list after try()

2012-11-27 Thread Jean V Adams
Create an empty list called "result" before you run the loop. Then store the results of the loop in the list. For example: result <- vector(mode="list", length=1000) for(i in 1:1000){ result[[i]] <- try(harvest(i)) } Jean mdvaan wrote on 11/27/2012 12:09:38 AM: > > Hi, >

[R] Accumulate objects in list after try()

2012-11-26 Thread mdvaan
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 =