[R] Replacing values job
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Wed Nov 28 17:24:42 CET 2007
jim holtman wrote:
> ?match
>
>> X
> [1] 2 6 1 7 4 3 5
>> Y
> [1] 1 1 6 4 6 1 4 1 2 3 6 6 1 2 4 4 5 4 1 7 6 6 4 4 7 1 2
>> match(Y,X)
> [1] 3 3 2 5 2 3 5 3 1 6 2 2 3 1 5 5 7 5 3 4 2 2 5 5 4 3 1
>
I quite like this solution:
> X[X[X[X[X[X[X[X[X[X[X]]]]]]]]]][Y]
[1] 3 3 2 5 2 3 5 3 1 6 2 2 3 1 5 5 7 5 3 4 2 2 5 5 4 3 1
but somehow I don't think its general enough...
Barry
More information about the R-help
mailing list