title: How to aggregate data in data.frame in R
body: <p>I have a large data.frame. The data.frame include a lot of values.</p>
  
  <p>For example:</p>
  
  <pre><code>df &lt;- data.frame(Company = c('A', 'A', 'B', 'C', 'A', 'B', 'B', 'C', 'C'), 
                   Name = c("Wayne", "Duane", "William", "Rafael", "John", "Eric", "James", "Pablo", "Tammy"), 
                   Age = c(26, 27, 28, 32, 28, 24, 34, 30, 25), 
                   Wages = c(50000, 70000, 70000, 60000, 50000, 70000, 65000, 50000, 50000), 
                   Education.University = c(1, 1, 1, 0, 0, 1, 1, 0, 1), 
                   Productivity = c(100, 120, 120, 95, 88, 115, 100, 90, 120))
  </code></pre>
  
  <p>How can I aggregate my <code>data.frame</code>? I want to analyze values on every Company. It must look like:</p>
  
  <p><a href="https://i.stack.imgur.com/jYEc8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jYEc8.png" alt="enter image description here"></a></p>
  
  <p>Age -> average Age of all employees in Company</p>
  
  <p>Wages -> average Wages of all employees in Company</p>
  
  <p>Education.University -> sum of factors (1 or 0) for all employees in Company</p>
  
  <p>Productivity -> average Productivity of all employees in Company</p>