title: How to create a new ordinal variable according to other variables?
body: <p>Hi to all the members of the community. 
  This question might seems identical to another that I asked some time before, so may be could be a repetition but the request output is definitely different from the previous question.</p>
  
  <p>I have the following DB:</p>
  
  <pre><code>ID1=rep((1:1),20)
  ID2=rep((2:2),20)
  ID3=rep((3:3),20)
  ID&lt;-c(ID1,ID2,ID3)
  DATE1=rep("2013-1-1",10)
  DATE2=rep("2013-1-2",10)
  DATE=c(DATE1,DATE2)
  IN&lt;-data.frame(ID,DATE=rep(DATE,3))
  </code></pre>
  
  <p>and I would like to create a new variable that could identify how many burst (a burst is defined as a cycle of observation within each day) were recorded for each id, like this:</p>
  
  <pre><code>IN$BURSTTRUE&lt;-rep(c(rep(1,10),rep(2,10)),3)
  </code></pre>
  
  <p>Until now I have try this solution (but unfortunately it doesn't work because it correctly identifies each burst, but not according to each id).</p>
  
  <pre><code>IN$BURST&lt;-with(IN,as.numeric(interaction(IN$ID,IN$DATE,lex.order=TRUE)))
  </code></pre>
  
  <p>I suppose that the function <code>ave</code> could be useful to solve this task: I tried several combinations but none work so I report the solution more near to the request output.
  As always any suggestion is greatly appreciate!</p>