title: duplicate rows and create new data frame in R
body: <p>I have a R data frame called intraPByGroup as follows:</p>
  
  <pre><code>group, week1, week2, week3, week4
  kiwi,23,43,54,23
  eggplant,22,32,33,63
  jasmine,23,454,12,654
  coconut,32,56,22,31
  </code></pre>
  
  <p>What I want to do is to create a new data frame which are like the following</p>
  
  <pre><code>user,week1,week2,week3,week4
  eggplantA,22,32,33,63
  eggplantB,22,32,33,63
  eggplantC,22,32,33,63
  jasmineA,23,454,12,654
  jasmineB,23,454,12,654
  jasmineC,23,454,12,654
  </code></pre>
  
  <p>Basically, the idea is: from the original data set, I select two groups (eggplant and jasmine), and I want to create a new dataframe. This new data frame has "user" variable instead of "group". Each user name is actually "groupname+A(B or C)", and all the rest values are duplicated for all users in the same group.</p>
  
  <p>How should I do that in R?</p>
  
  <p>I am thinking of firstly drop the group names and select a row, and compose one new row, then repeat doing this for each selected group.</p>
  
  <pre><code>eggFrame &lt;- intraPByGroup[intraPByGroup$group=="eggplant",-1]
  eggFrame1 &lt;- eggFrame
  eggFrame1["user"] &lt;- "Eggplant-A"
  eggFrame2 &lt;- eggFrame
  eggFrame2["user"] &lt;- "Eggplant-B"
  total &lt;- rbind(eggFrame1,eggFrame2)
  </code></pre>
  
  <p>I think repeatedly doing rbind is stupid, even in this way, is there any other faster ways to do it?</p>