title: How can I refer to another dataset to create a new vector for a separate dataset?
body: <p>I have two datasets of different length. In one dataset, it has a list of NBA players from 1996-2020. The other has the awards each player from 1996-2020 earned. I want my function to check how many awards a player has, and if they don't appear in the award dataset they get 0. final.frame$player_name and dpoy.num$player is the player name (they both have matching syntax like capitalization and name spelling), and dpoy.num$winner is how many times a player won the award. This is my function so far:</p>
  <pre><code>dpoy.finder &lt;- function(data.frame) {
    dpoy.vec &lt;- c()
    for (i in final.frame) {
      if (final.frame$player_name[i] == dpoy.num$player[i]){
        dpoy.vec[i] &lt;- dpoy.num$winner[i]
      } else if (final.frame$player_name[i] != dpoy.num$player[i]){
        dpoy.vec[i] &lt;- 0
      }}}
  }
  </code></pre>
  <p>final.frame is the dataframe with all of the player names and dpoy.num is the dataframe that has the counts of how many DPOY wins each player has for those who have won the award from 1996-2020. I want the function to run through the original dataframe, and if it finds a match, it will assign the amount of times that player won the award. Example would be Every player in final.frame without a DPOY has 0, Dwight Howard, having a value of 3 in the vector and Draymond Green having 1.</p>
  <p>Thank you</p>