title: R: a "code vector" from string output
body: <p>In a script I extract colnames from a data.frame like this:</p>
  
  <pre><code>colnames(df[2:3]
  [1] "Col1" "Col2" 
  </code></pre>
  
  <p>In order to keep these strings in the script no matter if the rownumbers change in df before running the script again, I want this output to be in the script like:</p>
  
  <pre><code>c("Col1", "Col2")
  </code></pre>
  
  <p>My Code now:</p>
  
  <pre><code>setnames(df2, colnames(df2$[2:3]), colnames(df[2:3]))
  </code></pre>
  
  <p>and I want it like this:</p>
  
  <pre><code>setnames(df2, colnames(df2$[2:3]), c("Col1", "Col2")]
  </code></pre>
  
  <p>How can I achieve this easily?</p>