title: Countif in R: Relational Vectors
body: <p>I'm new using R and I'm having an issue trying to perform a "countif" as in Excel.  What I have is below.  There are two vectors, vector1 being the possible values of vector2.  Vector1 numbers include team_ids to represent the possible teams that may win a game in a tournament. Vector2 is the result of a simulation.</p>
  
  <p>The reason why I can't use a table to summarize the simulation is that many teams won't be represented in game63, but I would still like to return a 0.</p>
  
  <p>In the end, I would like to add a vector possible_teams_prob that counts the number of times each item in possible_teams is in game63.  This way I can combine into a final possible table that has the teams listed along with their probabilities of winning game63.</p>
  
  <pre><code>&gt; possible_teams &lt;- seq(1,64)
  &gt; possible_teams
  [1]  1  2  3  4  5  6  7  8  9 10 11 12
  [13] 13 14 15 16 17 18 19 20 21 22 23 24
  [25] 25 26 27 28 29 30 31 32 33 34 35 36
  [37] 37 38 39 40 41 42 43 44 45 46 47 48
  [49] 49 50 51 52 53 54 55 56 57 58 59 60
  [61] 61 62 63 64
  
  &gt; game63[1:20]
  [1]  4  8  4  4  3 20  2  3  3  1  3 20
  [13]  3  8  2  4  3  1 14  3
  </code></pre>