title: How to generate number sequence 1,2,5,6,9,10,13,14,
body: <p>I want to generate an alternating sequence, to enter them into a dataframe in R. Always two of each element (in my case: 2x daughter, 2x mother). In my specific example, I use the indices 1,2,5,6,9,10, etc.</p>
  
  <p>My desired output is a dataframe of the form:</p>
  
  <pre><code>df &lt;- data.frame(values=c(sample(1:8)), relation=c("daughter", "daughter", "mother", "mother", "daughter", "daughter", "mother", "mother"))
  df
  
    values relation
  1      4 daughter
  2      3 daughter
  3      2   mother
  4      8   mother
  5      1 daughter
  6      5 daughter
  7      6   mother
  8      7   mother
  </code></pre>
  
  <p>I can find the correct index to replace the initial entries with this:</p>
  
  <pre><code>daughter_id &lt;- sort(c(seq(1,20, 4), seq(2,20, 4)))
  mother_id &lt;- sort(c(seq(3,20, 4), seq(4,20, 4)))
  </code></pre>
  
  <p>It works and allows me to enter my desired values:</p>
  
  <pre><code>df[daughter_id ,"relation"] &lt;- "daughter"
  df[mother_id,"relation"] &lt;- "mother"
  </code></pre>
  
  <p>But is there a simpler solution?
  And is there a solution that directly inserts certain values n times?</p>