title: Expand rows in R to fulfill quota
body: <p>I have the following dataframe, <code>main_df</code>. </p>
  
  <pre><code>structure(list(Id = c(190150L, 243744L, 204796L, 139630L, 156541L, 
  157377L, 225627L), Name = c("Columbia University in the City of New York", 
  "Stanford University", "Ohio State University-Main Campus", "Emmanuel    College", 
  "University of the Cumberlands", "Midway University", "University of the Incarnate Word"
  ), desired_sport = c("Archery", "Synchronized Swimming", "Synchronized Swimming", 
  "Archery", "Archery", "Archery", "Synchronized Swimming"), academic_strength =   c("elite", 
  "elite", "average", "weak", "weak", "weak", "weak")), .Names = c("Id", 
  "Name", "desired_sport", "academic_strength"), class = "data.frame", row.names = c(1L, 
  258L, 1043L, 1144L, 1145L, 1146L, 1500L))
  </code></pre>
  
  <p>I need to have different desired sports and different levels of academic strengths.
  At minimum, I need a dataframe that has at least 3 rows in each of the combinations of <code>desired_sport</code> and <code>academic_strength</code>. </p>
  
  <p>In order to find that, I created a separate df to see how many were present in each combination</p>
  
  <p><code>aggregate_test_df &lt;- aggregate(Id ~ desired_sport + academic_strength, main_df, length)</code></p>
  
  <p>I then created a new df with the maximum combinations that I needed and thought I could "cbind" the extra columns and then fill in the remainder. </p>
  
  <p>The new combination_test_df was created as follows:</p>
  
  <pre><code>academic_strength &lt;- c("elite", "strong", "average", "weak")
  sport_test &lt;- c("Archery", "Synchronized Swimming")
  
  combination_test_df &lt;- expand.grid(sport_test, academic_strength)
  i &lt;- sapply(combination_test_df, is.factor)
  combination_test_df[i] &lt;- lapply(combination_test_df[i], as.character)
  
  combination_test_df$count &lt;- 3
  combination_test_df2 &lt;- expandRows(combination_test_df, "count")
  </code></pre>
  
  <p>And got stuck in that I could not merge or cbind without creating more combinations. </p>
  
  <p>The desired output would be a dataframe with each "desired_sport", "academic_strength" combination 3 times, some will be NA and some will be filled in, but that will allow me to create rules to fill in the NA's for the "name" and the "Id" columns.</p>
  
  <p>Output would look like a dataframe similar to this:</p>
  
  <pre><code>Id  Name    desired_sport   academic_strength
  190150  Columbia University in the City of New York Archery elite
  NA  NA  Archery elite
  NA  NA  Archery elite
  NA  NA  Archery strong
  NA  NA  Archery strong
  NA  NA  Archery strong
  NA  NA  Archery average
  NA  NA  Archery average
  NA  NA  Archery average
  139630  Emanuel College Archery weak
  156541  University of the Cumberlands   Archery weak
  157377  Midway University   Archery weak
  243744  Stanford University Synchronized Swimming   elite
  NA  NA  Synchronized Swimming   elite
  NA  NA  Synchronized Swimming   elite
  NA  NA  Synchronized Swimming   strong
  NA  NA  Synchronized Swimming   strong
  NA  NA  Synchronized Swimming   strong
  204796  Ohio State University - Main Campus Synchronized Swimming   average
  NA  NA  Synchronized Swimming   average
  NA  NA  Synchronized Swimming   average
  NA  NA  Synchronized Swimming   weak
  NA  NA  Synchronized Swimming   weak
  NA  NA  Synchronized Swimming   weak
  </code></pre>
  
  <p>And then i would actually like to be able to fill in- so the complete final dataframe</p>
  
  <pre><code>Id  Name    desired_sport   academic_strength
  190150  Columbia University in the City of New York Archery elite
  139630  Emanuel College Archery elite
  156541  University of the Cumberlands   Archery elite
  139630  Emanuel College Archery strong
  156541  University of the Cumberlands   Archery strong
  157377  Midway University   Archery strong
  139630  Emanuel College Archery average
  156541  University of the Cumberlands   Archery average
  157377  Midway University   Archery average
  139630  Emanuel College Archery weak
  156541  University of the Cumberlands   Archery weak
  157377  Midway University   Archery weak
  243744  Stanford University Synchronized Swimming   elite
  204796  Ohio State University - Main Campus Synchronized Swimming   elite
  NA  NA  Synchronized Swimming   elite
  204796  Ohio State University - Main Campus Synchronized Swimming   strong
  NA  NA  Synchronized Swimming   strong
  NA  NA  Synchronized Swimming   strong
  204796  Ohio State University - Main Campus Synchronized Swimming   average
  NA  NA  Synchronized Swimming   average
  NA  NA  Synchronized Swimming   average
  NA  NA  Synchronized Swimming   weak
  NA  NA  Synchronized Swimming   weak
  NA  NA  Synchronized Swimming   weak
  </code></pre>
  
  <p>Any advice?</p>