title: Redefining several time series at once in R
body: <p>I have 37 time series, and each has 9 columns.
  I want to lag 3 of these 9 columns.</p>
  
  <p>Suppose that my time series are named TS1.xts, ..., TS37.xts and I want to do</p>
  
  <pre><code>TS1.xts$col1 &lt;- lag.xts( TS1.xts$col1 )
  TS1.xts$col1 &lt;- lag.xts( TS1.xts$col1 )
  TS1.xts$col3 &lt;- lag.xts( TS1.xts$col3 )
  </code></pre>
  
  <p>Logically, I do not what to write this piece 37 times. I have a list </p>
  
  <pre><code>time.series &lt;- c('TS1', ... , 'TS37')
  </code></pre>
  
  <p>And I tried to </p>
  
  <pre><code>for(ts in time.series){
    assign(paste0(ts, '.xts$col1'), lag.xts( parse(text=paste0(ts, '.xts$col1'))));
    assign(paste0(ts, '.xts$col2'), lag.xts( parse(text=paste0(ts, '.xts$col2'))));
    assign(paste0(ts, '.xts$col3'), lag.xts( parse(text=paste0(ts, '.xts$col3')))); }
  </code></pre>
  
  <p>But R keeps throwing the following error: '}' unexpected in "}".</p>
  
  <p>I don't understand what this means and I have no idea how to do this code in any other way. I also tried to evaluate the expression inside the <code>lag.xts()</code> with <code>eval()</code></p>
  
  <p>Any help is appreciated.</p>