title: conditionally fill dataframe column based on a range of values from 2 columns
body: <p>I currently have this loop to trim rows from a dataset (df_2) based on a range of indices, the start and end indices for the sections to include being taken from 2 columns in df_3, and create a new file (df).</p>
  
  <pre><code>for(i in 1:nrow(df_3)){
    if (i==1) df &lt;- df_2[df_3$start[i]:df_3$end[i],]
    else df &lt;- rbind(df,df_2[df_3$start[i]:df_3$endi],])
  }
  </code></pre>
  
  <p>Each section has a value associated with it, which is contained in column 3 of df_3. I want to create a new column in df that repeats the values associated with that section.</p>
  
  <p>Would really appreciate some assistance here feel free to ask for clarification - was as succinct as I could make it!</p>
  
  <p>As suggested by Joran - here are some examples</p>
  
  <p>DF</p>
  
  <pre><code>index  new_column
  0     
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  </code></pre>
  
  <p>DF_3</p>
  
  <pre><code>start  _end  new_column_values
  
  0      3     1
  4      6     2
  7      10    3
  </code></pre>