title: R quantile by groups with assignments
body: <p>I have the following df:</p>
  
  <pre><code>group = rep(seq(1,3),30)
  variable = runif(90, 5.0, 7.5)
  df = data.frame(group,variable)
  </code></pre>
  
  <p>I need to i) Define quantile by groups, ii) Assign each person to her quantile with respect to her group.</p>
  
  <p>Thus, the output would look like:</p>
  
  <pre><code>id    group  variable  quantile_with_respect_to_the_group
  1      1      6.430002     1
  2      2      6.198008     3
            .......
  </code></pre>
  
  <p>There is a complicated way to do it with loops and cut function over each groups but it is not efficient at all. Does someone know a better solution ?   </p>
  
  <p>Thanks !</p>