title: Create a new column per group based on condition in a data frame
body: <p>although I searched long for solutions, e.g. 
  <a href="https://stackoverflow.com/questions/32214654/assign-value-to-group-based-on-condition-in-column">Assign value to group based on condition in column</a></p>
  
  <p>I am not able to solve the following problem and would appreciate greatly any help!</p>
  
  <p>I have the following data frame (in reality, many more with thousands of rows):</p>
  
  <pre><code>df &lt;- data.frame(ID1 = c(1,1,1,2,2,2,2,3,3,4,4,4,5,5,5,6,6,6,7,7), 
               ID2 = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20), 
               Percentage = c(0,10,NA,65,79,81,52,0,0,11,12,35,0,24,89,76,0,NA,59,16), 
               Group_expected_result = c(6,6,6,7,7,7,7,1,1,3,3,3,4,4,4,5,5,5,2,2))
  </code></pre>
  
  <p>What I want to do is to assign a group type from 1 to 7 to each group as indicated by ID1. Which group type should be assigned is dependent on the conditions of column 3, Percentage (can have values from 0-100) and is split into seven types:</p>
  
  <p>Type 1 has a percentage of 0, i.e.</p>
  
  <ul>
  <li>Type 1 = 0</li>
  <li>Type 2 > 0 &amp; &lt; 10 </li>
  <li>Type 3 > 9 &amp; &lt; 20 </li>
  <li>Type 4 > 19 &amp; &lt; 30</li>
  <li>Type 5 > 29 &amp; &lt; 40 </li>
  <li>Type 6 > 39 &amp; &lt; 50 </li>
  <li>Type 7 > 49</li>
  </ul>
  
  <p>The combination of these types (above) defines the group type (G1-G7) below: </p>
  
  <ul>
  <li>G1   = only T7</li>
  <li>G2   = only T7 &amp; T2-T6</li>
  <li>G3   = only T2-T6</li>
  <li>G4   = at least one T1, &amp; one T2-T6, &amp; one T7 (= all)</li>
  <li>G5   = only T7 &amp; T1</li>
  <li>G6   = only T2-T6 &amp; T1</li>
  <li>G7   = only T1</li>
  </ul>
  
  <p>The expected result is in the last column of the sample data frame, e.g.
  the first group consists of types T1 and T2, therefore should be group type G6.</p>
  
  <p>So, the question is how to get the expected result in the last column? I hope I made the problem clear! Thanks in advance!</p>