title: MATCH function in r
body: <p>have lists, the first one (list1) has id,name,age and the other ones (list2,list3,..) has ids and test value (unique).</p>
  
  <p>list 1:</p>
  
  <pre><code>id  age name    bio-test    
  1   40  danny
  2   16  nora            
  3   35  james
  4   21  ben
  </code></pre>
  
  <p>list 2 (bio-test):</p>
  
  <pre><code>id  test passed year   
  1   100   yes   1
  5   80    yes   n/a      
  4   55    no    2
  </code></pre>
  
  <p>I am trying to add to list1 the test value to each id (not every id have a test value).</p>
  
  <p>this is part of the code:</p>
  
  <pre><code>for (i in 1:length(list1)) { 
  list1$test1value &lt;- list2$test[match(list1$id[i], list2$id[i]),
  nomatch = NA_integer_, incomparables = NULL)] }
  </code></pre>
  
  <p>but instead looking up the test value by id ,it copied just the first test value from list2 and copied it to 200 cells and the other 3000 are N/A.</p>
  
  <p>what is wrong?</p>