I have defined a custom function, like this:
my.fun = function() { for (i in 1:1000) { ... for (j in 1:20) { ... } }
Try this:
final <- replicate(5, my.fun(), simplify = "matrix")
You will get the result of 'final' in the form of matrix.