[R] how to do this "the R way"

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Apr 3 16:06:13 CEST 2009



onyourmark wrote:
> 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]]. ... ,

Perhaps you can explain what the last line is supposed to do? This is 
invalid R code and also not a known mathematical notation for me ....

Uwe Ligges


> perm[100.TS2[2000]])
> 
> Is there a nice way to do this without a loop?
> 
> Thank  you.




More information about the R-help mailing list