title: Calculations across more than two different dataframes in R
body: <p>I'm trying to transfer some work previously done in Excel into R. All I need to do is transform two basic count_if formulae into readable R script. In Excel, I would use three tables and calculate across those using 'point-and-click' methods, but now I'm lost in how I should address it in R.</p>
  
  <p>My original dataframes are large, so for this question I've posted sample dataframes:</p>
  
  <pre><code>OperatorData &lt;- data.frame(
                      Operator = c("A","B","C"),
                      Locations = c(850, 575, 2175)
   )
  
  AreaData &lt;- data.frame(
                Area = c("Torbay","Torquay","Tooting","Torrington","Taunton","Torpley"),
                SumLocations = c(1000,500,500,250,600,750)
   )
  
  OperatorAreaData &lt;- data.frame(
                Operator = c("A","A","A","B","B","B","C","C","C","C","C"),
                Area = c("Torbay","Tooting","Taunton",
                         "Torbay","Taunton","Torrington",
                         "Tooting","Torpley","Torquay","Torbay","Torrington"),
                Locations = c(250,400,200,
                              100,400,75,
                              100,750,500,650,175)
   )
  </code></pre>
  
  <p>What I'm trying to do is add two new columns to the OperatorData dataframe: one indicating the count of Areas that operator operates in and another count indicating how many areas in which that operator operates in <strong>and</strong> owns more than 50% of locations.</p>
  
  <p>So the new resulting dataframe would look like this</p>
  
  <pre><code>Operator     Locations   AreaCount    Own_GE_50percent
  A            850         3            1
  B            575         3            1
  C            2715        5            4
  </code></pre>
  
  <p>So far, I've managed to calculate the first column using the table function and then appending:</p>
  
  <pre><code>OpAreaCount &lt;- data.frame(table(OperatorAreaData$Operator))
  names(OpAreaCount)[2] &lt;- "AreaCount"
  OperatorData$"AreaCount" &lt;- cbind(OpAreaCount$AreaCount)
  </code></pre>
  
  <p>This is fairly straightforward, but I'm stuck in how to calculate the second column calculation with the condition of 50%.</p>