How do I retrieve outputs from objects in an array as described in the background?
I have a function in R that returns multiple variables. For eg. if my function is called function_ABC
,then:
a<-function_ABC (input_var)
gives a
such that a$var1
, a$var2
, and a$var3
exist.
I have multiple cases to run such that I have put then in an array:
input_var <- c(1, 2, ...15)
for storing the outputs, I declared var such that:
var <- c(v1, v2, v3, .... v15)
Then I run:
assign(v1[i],function(input_var(i)))
However, after that I am unable to access these variables as v1[1]$var1
. I can access them as: v1$var1
, or v3$var1
, etc. But this means I need to write 15*3 commands to retrieve my output.
Is there an easier way to do this?