title: How to create dynamic columns in XTS
body: <p>Imagine I have a XTS object called SP500 and I would like to create new columns like this:</p>
  
  <pre><code>SP500$Cierre1 = lag(SP500$Cierre, k=1)
  SP500$Cierre2 = lag(SP500$Cierre, k=2)
  SP500$Cierre3 = lag(SP500$Cierre, k=3)
  SP500$Cierre4 = lag(SP500$Cierre, k=4)
  SP500$Cierre5 = lag(SP500$Cierre, k=5)
  </code></pre>
  
  <p>What I want is another way to create these columns but using a variable like this in R:</p>
  
  <pre><code>i = 11
  
  SP500$(paste("Cierre",i)) = lag(SP500$Cierre, k=i)
  </code></pre>
  
  <p>Any idea?</p>
  
  <p>Thank you very much in advance.</p>