title: How can I addapt the size of 2 data frames based in the content of a column?
body: <blockquote>
    <p>I would like to solve this in R</p>
  </blockquote>
  
  <p>I have two data frames of the different numbers of rows, and for one of the columns they have the same content but one of them with more repetitions. I would like to duplicate the row in the smaller data frame to adapt to the size of the bigger data frame whenever this happens. </p>
  
  <p>So let's say the columns I want to compare loos like this</p>
  
  <pre><code>df_small$column2&lt;-c("A", "B","C");
  df_big$column3&lt;-c("A", "B","B","B","C","C")
  </code></pre>
  
  <p>I would like to replicate the rows containing B two times in <code>df_small</code>, and replicate once the row containing "C". I tried something like this.</p>
  
  <pre><code>i=1
  while (i &lt;= nrow(df_big)) {
    if (df_big$column3[i+1]==df_small[i,2]){
      df_small&lt;-rbind(df_small, df:small[i,1:2]) #df_small has two columns
      i=i+1
    } else{
      i=i+1
      next
    }
  
  }
  </code></pre>
  
  <p>This is not working. I am not really familiar with loops in R and I don´t know where the mistake is. Thanks in advance for your help!</p>