title: R extend vectors to be the same length around central value
body: <p>Let's suppose I have a list:</p>
  
  <pre><code>[[1]]
   [1]  0.7125856 -1.4871811  0.6230076  1.0756424  0.8172592 -0.1327926 -0.7674947 -1.0738684  1.5706677
  [10] -0.6674960
  
  [[2]]
  [1] -0.5778682 -1.1186447  0.8272505  0.5123162  0.6607654  1.6559877 -0.7961859 -0.8966686
  
  [[3]]
   [1] -1.42867999 -0.21142100 -2.89762370  0.11036288  0.66846399 -0.77309213  0.35278541 -0.99579117 -0.73043142
  [10] -0.01857864 -0.93654969  0.46751328
  
  [[4]]
  [1] -0.483896685 -0.207550362 -0.902920637 -0.008191134 -1.015636093
  </code></pre>
  
  <p>And I also have a vector with indices of so-called "central" values of vectors in this list:</p>
  
  <pre><code>[1] 2 4 5 1
  </code></pre>
  
  <p>What I'm trying to get is for given range (for example, 3) get subsets of vectors around those centers with the length of range in both sides. So every subset must be length of 7 and if range extends beyond length of vector there must be NAs added:</p>
  
  <pre><code>[[1]]
  [1]         NA         NA  0.7125856 [-1.4871811]  0.6230076  1.0756424  0.8172592
  
  [[2]]
  [1] -0.5778682 -1.1186447  0.8272505  [0.5123162]  0.6607654  1.6559877 -0.7961859
  
  [[3]]
  [1] -0.2114210 -2.8976237  0.1103629  [0.6684640] -0.7730921  0.3527854 -0.9957912
  
  [[4]]
  [1]           NA           NA           NA [-0.483896685] -0.207550362 -0.902920637 -0.008191134
  </code></pre>
  
  <p>I put centers in brackets, because SO doesn't allow bold text in a code. Is there a way to do something like this in R?</p>