title: Lag multiple variables multiple times in R
body: <p>So, I'm working with a data frame that has daily data over a period of 444 days. I have several variables that I want to lag for use in a regression model (<code>lm</code>). I want to lag them 7 times each. I'm currently generating the lags like this...</p>
  
  <pre><code>email_data$email_reach1 &lt;- lag(ts(email_data$email_reach, start = 1, end = 444), 1)
  email_data$email_reach2 &lt;- lag(ts(email_data$email_reach, start = 1, end = 444), 2)
  email_data$email_reach3 &lt;- lag(ts(email_data$email_reach, start = 1, end = 444), 3)
  email_data$email_reach4 &lt;- lag(ts(email_data$email_reach, start = 1, end = 444), 4)
  email_data$email_reach5 &lt;- lag(ts(email_data$email_reach, start = 1, end = 444), 5)
  email_data$email_reach6 &lt;- lag(ts(email_data$email_reach, start = 1, end = 444), 6)
  email_data$email_reach7 &lt;- lag(ts(email_data$email_reach, start = 1, end = 444), 7)
  </code></pre>
  
  <p>Then, I repeat this for every single variable I want to lag.</p>
  
  <p>This seems like a terrible way of accomplishing this. Is there something better?</p>
  
  <p>I've thought about lagging the entire data frame, which works, but I don't know how you'd assign variable names to the result and merge it back to the original data frame.</p>