I have a following vector called cases as follows:
cases = [1,4,4,3,1,2,2,4,3,4,4,...];
Additionally, I have four arrays Array1 to Array4.
Now I want to construct a new Array, where the elements of this new array are picked from the Array1,...,Array4 depending on what the "cases" array indicates. So for instance, the first element of cases is "1" which means to pick from Array 1 (and I would like to do this in the right order, so I pick the first element of Array1). Then the second element of cases is a "4", so now I want to sample from Array 4, again the first element. The next element of cases is again "4", now I pick the second element of Array4 and so on. How can I do that effectively? The only thing which comes to my mind is to loop with ifelse loops, but that seems rather not so straightforward. Thanks