title: Ordering column in dataframe by specific sequence in R
body: <p>I am working on a data frame similar to this one here:</p>
  
  <pre><code>ID = c("1","1","1","1","1","1","1","2","2","2","2","2","2","2","2","2","2","2","2","2","2") 
  TIME = c("0", "0.5", "1","1.5","2","2.5","3","0","0", "0.5","0.5", "1","1","1.5","1.5","2","2","2.5","2.5","3","3") 
  OBS = c("0", "0.73", "0.98", "1.24", "2.06","2.56","4.01", "0", "0.03", "0.76", "0.85", "2.13","2.78","3.9", "4.1", "5.4", "5.6", "7.8", "8.0","8.4","8.8") 
  VISITNUM = c("1","1","1","1","1","1","1","1","2", "1","2","1","2","1","2","1","2","1","2","1","2") 
  DF = data.frame(ID, TIME, OBS, VISITNUM)
  </code></pre>
  
  <p>I am having trouble ordering the data frame - basically I want to order my data by the following time sequence: </p>
  
  <pre><code>TIMEORDERED &lt;- c("0","0.5","1","1.5","2","2","2.5","3")
  </code></pre>
  
  <p>giving this</p>
  
  <pre><code>ID = c("1","1","1","1","1","1","1","2","2","2","2","2","2","2","2","2","2","2","2","2","2") 
  TIME = c("0", "0.5", "1","1.5","2","2.5","3","0", "0.5", "1","1.5","2","2.5","3","0", "0.5", "1","1.5","2","2.5","3") 
  OBS= c("0", "0.73", "0.98", "1.24", "2.06","2.56","4.01", "0", "0.76", "2.13","3.9", "5.4", "7.8", "8.4", "0.03", "0.85", "2.78", "4.1","5.6","8.0","8.8") 
  VISITNUM = c("1","1","1","1","1","1","1","1","1","1","1","1","1","1","2","2","2","2","2","2","2")
  DFIWANT = data.frame(ID, TIME, OBS, VISITNUM) 
  </code></pre>
  
  <p>The issue is there are measurements on the same subject (DF$ID = 2) (yet different visits, see DF$VISITNUM).</p>
  
  <p>I suspect the order() function or the arrange() function in the plyr package are my friends, yet my attempts have not been fruitful. </p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Sincerily
  Y</p>