title: rdata: Some method to iterate through column names of a data frame?
body: <p>I have about 30 lines of code that do just this (getting Z scores):</p>
  
  <pre><code>data$z_col1 &lt;- (data$col1 - mean(data$col1, na.rm = TRUE)) / sd(data$col1, na.rm = TRUE)
  data$z_col2 &lt;- (data$col2 - mean(data$col2, na.rm = TRUE)) / sd(data$col2, na.rm = TRUE)
  data$z_col3 &lt;- (data$col3 - mean(data$col3, na.rm = TRUE)) / sd(data$col3, na.rm = TRUE)
  data$z_col4 &lt;- (data$col4 - mean(data$col4, na.rm = TRUE)) / sd(data$col4, na.rm = TRUE)
  data$z_col5 &lt;- (data$col5 - mean(data$col5, na.rm = TRUE)) / sd(data$col5, na.rm = TRUE)
  </code></pre>
  
  <p>Is there some way, maybe using <code>apply()</code> or something, that I can just essentially do (python):</p>
  
  <pre><code>for col in ['col1', 'col2', 'col3']:
      data{col} = ... z score code here
  </code></pre>
  
  <p>Thanks R friends.</p>