[R] A particular shuffling on a vector
emmanuel.levy at gmail.com
Fri Apr 20 03:03:01 CEST 2007
I was wondering if anyone can think of a straightforward way (without
loops) to do the following shuffling:
Let's imagine a vector:
I would like to derive shuffled vectors __where the same digits are
never separated__, although they can be at both ends (periodicity).
So the following shuffled vectors are possible:
I should mention that there can be any number of different numbers,
and any number of repetition of each number.
So the vectors I have to deal with could look like
c(1,1,2,3,4,5,6,6,6,6,6,6,6,6,7,8) for example
Since I have to derive many shuffled versions for each vector, I am
looking for an efficient way of doing it. Can you think of a way
without nested loops?
Many thanks for your help,
More information about the R-help