Apologies for this question - I'm sure the answer is v simple
I have a couple of lists containing objects. I'm running them into HTML through knitr and want to control the order of the output.
This code prints all the list1 output, then all the list1 plots, then all the list2 output then all list2 plots
lapply(1:4, function(i){
my.list1[[i]]
plot(my.list1[[i]])
my.list2[[i]]
plot(my.list2[[i]])
})
I want it to print the first list1 output, then the first list1 plot then the first list2 output, then the first list2 plot. Then move onto the second interation of the loop.
Put another way, I want the function to complete all commands before iterating, rather than completing all iterations before moving to the next command.
Can this be done?
Thanks