title: How to fill a list based off of other items in the list in R?
body: <p>I have a list that looks like this:</p>
  
  <pre><code>n &lt;- c(1, rep(NA, 9), 2, rep(NA, 9))
  </code></pre>
  
  <p>I want the 9 observations following the first observation to contain the same value as the first observation.  And continue this pattern throughout the whole list.  So ideally, I want my list to look like this:</p>
  
  <pre><code>c(rep(1, 10), rep(2, 10))
  </code></pre>
  
  <p>I want to accomplish this without using for loops, is there a way to do this?</p>