title: Issue with merge statement
body: <p>My merge does not seem to be working anymore and I do not why. Below is the code and the sample of the two data sets I am merging </p>
  
  <pre><code>head(lookup.table)
  
     code label
  1:  I-2     1
  2:  I-3     2
  3:  I-4     3
  4:  I-5     4
  5:  I-6     5
  6:  I-7     6  
  
  df 
             Rate
  1            S-4
  2            S-4
  3            S-4
  4            S-1
  5            S-2
  6            S-4
  </code></pre>
  
  <p>Code to reproduce the example</p>
  
  <pre><code>library(data.table)
  
  letter=c('I','S','P','D')
  start=c(2,1,1,1)
  end=c(7,4,3,2)
  label=1:15
  code.table = data.table(letter,start,end)
  code.vector = unlist(apply(code.table,1,function(x) paste(x[1],x[2]:x[3],sep='-')))
  lookup.table = data.table(code=code.vector,label=label)
  
  df = data.table(Rate = paste0("S-", c(4,4,4,1,2,4)))
  </code></pre>
  
  <p>Attempt:</p>
  
  <pre><code>df$rank = merge(df,lookup.table,by.x="Rate",by.y="code",all.x=TRUE,sort=F)$label
  </code></pre>
  
  <p>Below a sample of the output, and the merge is not producing the expected results. I am expecting the merge to join the lookup.table and df when code=Rate. </p>
  
  <pre><code>                 rank           Rate
  1                  10            S-4
  2                  10            S-4
  3                  10            S-3
  4                  10            I-5
  5                  10            I-5
  6                  10            I-6
  </code></pre>