title: "longer object length is not a multiple of shorter object length"
body: <p>I have this dataset - </p>
  
  <pre><code>print(df)
  
    object    group   
  1 apple      A    
  1 banana     B    
  1 pear       A    
  1 robot      C
  
  print(df2)
  
    object    group   
  1 apple      A    
  1 apple      B    
  1 apple      A    
  1 robot      C
  1 robot      C
  1 robot      C
  1 banana     C
  </code></pre>
  
  <p>I'd like to count the number of times each value shows up in another data set, which looks exactly the same but draws data from a different time period. The other dataset is called <code>df2</code>.</p>
  
  <p>I used this code - </p>
  
  <pre><code>x &lt;- df %&gt;%
    mutate(reference = length(df2[df2$object == object,]$object))
  </code></pre>
  
  <p>It gave me this error: <code>longer object length is not a multiple of shorter object length</code>. </p>
  
  <p>It works when I run this outside of dplyr, like this - </p>
  
  <pre><code>object &lt;- "apple"
  length(df2[df2$object == object,]$object)
  </code></pre>
  
  <p>Can I do a relative reference like that, including <code>object</code> in the filter?</p>