title: R - Create new variable in a data set by matching and a variable in another data set of different dimension
body: <p>I am trying to crate and append a new variable to a data set whose values will come from matching variable value of another data set.</p>
  
  <p>For example</p>
  
  <pre><code>    data set 1
          A B
          1 a
          2 b
          3 c
      data set 2
          A 
          1
          2
          3
          1
          3
          2
  </code></pre>
  
  <p>And I want my result to look like</p>
  
  <pre><code>data set 2
      A B
      1 a
      2 b
      3 c
      1 a
      3 c
      2 b
  </code></pre>
  
  <p>I tried to use below "Match" function to obtain the result</p>
  
  <pre><code>data set 2$B &lt;- data set 1$B[match(data set 1$A, data set 2$A)]
  </code></pre>
  
  <p>But it was throwing an error that there are</p>
  
  <pre><code>incorrect number of dimensions
  </code></pre>
  
  <p>How to deal with this? Please note that i don't want to merge both data sets because data set 2 contains hundreds or other variables.</p>
  
  <p>The question was put to deal with the dimension error too.</p>
  
  <p>Thanks, Mrinal</p>