Skip to content
Prev 175968 / 398503 Next

how to do this "the R way"

Hi. I am sure there is a better way in R to do this then using a loop but I
am new to it and not sure what to do. I think it might be something about
using a function as an argument but not sure.

I have a 1 x 2000 vector TS2 which has entries from the set {x: x is in Z
and 0<x<8} (where Z is the set of Integers).

Then I also have a 5050 x 7 matrix called 'perm' whose entries are also from
the set {x: x is in Z and 0<x<8}

I want to construct the following transformation of TS2 which will still be
a vector of size 1 x 2000 and which I will call 'newTS2' such that:

newTS2 =(perm[100.TS2[1]]. perm[100.TS2[2]]. perm[100.TS2[3]]. ... ,
perm[100.TS2[2000]])

Is there a nice way to do this without a loop?

Thank  you.