title: %in% resulting in null output
body: <p>dataset 1</p>
  
  <pre><code>location
  Bhilai, C.G
  Delhi
  Dadar, Mumbai
  Bangalore, India
  </code></pre>
  
  <p>dataset 2</p>
  
  <pre><code>location  state
  Bhilai    C.G
  Delhi     Delhi
  Dadar     Maharastra
  Bangalore Karnataka
  </code></pre>
  
  <p>I want an output like this</p>
  
  <p>output</p>
  
  <pre><code>location                 state
  Bhilai, C.G              C.G
  Delhi                    Delhi
  Dadar, Mumbai            Maharashtra
  Bangalore, India         Karnatak
  </code></pre>
  
  <p>a</p>
  
  <p>Used code:</p>
  
  <pre><code>&gt;    loc$key = 1
  &gt;    location2$key = 1
  &gt;    newdataset &lt;- merge(loc, location2, by="key")
  &gt;    newdataset &lt;- newdataset[newdataset$location.y %in% newdataset$location.x,
           c("location.x", "state")]
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>[1] location.x state.y   
  &lt;0 rows&gt; (or 0-length row.names)
  </code></pre>