I have a bit tricky challenge in looping which I would want to do in r to make things faster. How do I assign a sequence of small computations to a sequence of variables? Example:
fex1 = rbind(ben1,mal1)
fex2 = rbind(ben2,mal2)
fex3 = rbind(ben3,mal3)
....
....
fex40 = rbind(ben40,mal40)
where ben(i) and mal(i) are 7 by 13 matrix of sequence 1:40 and fex(i) is also a sequence of variable names 1:40. Basically, I have split some data into various folds and would like to rbind a combination of the split datasets to perform some other computation. I have used lapply to loop over rbind and other functions but how do I achieve this task applying a function like rbind over a sequence of matrices and storing the values also in a sequence of variables?
Thanks.
You should really use a list here:
If you must have separate variables, use
assign
:NOTE to collect your objects into a list:
However, you should also try to place them in a list from the getgo.