title: Replacing seconds since the epoch with ordered digits in R
body: <p>I have a dataset where the timestamp is in seconds since the epoch:</p>
  
  <pre><code>   id      event       time       
  2 722     opened 1356931342
  1 723     opened 1356963741
  4 721 referenced 1356988186
  5 721     closed 1356988186
  3 721 referenced 1356988206
  </code></pre>
  
  <p>However, because processing a large number of very long time stamps creates serious performance issues with the algorithm that I'm using (optimal matching distances), I want to reduce this to a simple ordering of which event came first (or at the same time). By this I mean is that the earliest event (row) in the dataset should be 1, then 2, 3, 4, etc. If two rows have exactly the same number (seconds since the epoch), they need to be given the same number in the new, reduced format. Hence, this would need to output something along the lines of:</p>
  
  <pre><code>   id      event       time       
  2 722     opened       1
  1 723     opened       2
  4 721 referenced       3
  5 721     closed       3
  3 721 referenced       4
  </code></pre>
  
  <p>Where the "time" column is essentially a vector of numbers (not factors - this will not work since I'm trying to solve a performance issue).</p>
  
  <p>I can order the dataframe using:</p>
  
  <pre><code>df &lt;- df[with(df, order(time)), ]
  </code></pre>
  
  <p>However, how do I replace the numbers with ordered single digits (same number for equal time stamps)?</p>