title: In R, how do I locally shuffle a vector's elements
body: <p>I have the following vector in R. Think of them as a vector of numbers.</p>
  
  <pre><code>x = c(1,2,3,4,...100)
  </code></pre>
  
  <p>I want to randomize this vector "locally" based on some input number the "locality factor". For example if the locality factor is 3, then the first 3 elements are taken and randomized followed by the next 3 elements and so on. Is there an efficient way to do this? I know if I use sample, it would jumble up the whole array.
  Thanks in advance</p>