title: Pasting in a for loop
body: <p>I have a number of <code>data.frame</code>s that I want to export to Excel using the package <code>XLConnect</code>. I'm doing this using a <code>for</code> loop, within the loop there is a <code>paste</code> function that gives the <code>sheet</code> name but I don't know how to construct the <code>data</code> name.</p>
  
  <p>Here's what I mean.</p>
  
  <p>My <code>data.frame</code>s are named as follows,</p>
  
  <pre><code>port.1a, port.1b, port.2a, port.2b ... port.10a, port.10b
  </code></pre>
  
  <p>So far my code looks like this,</p>
  
  <pre><code>library(XLConnect)
  for (i in 1:10){
      a[i]  &lt;- paste("port.",i,"a",sep="")
      b[i]  &lt;- paste("port.",i,"a",sep="")
      writeWorksheetToFile("wfe_bx3.xlsx", data=b[i], sheet=a[i])
  }
  </code></pre>
  
  <p>I haven't bother with the <code>port.1b</code> <code>data.frame</code>s as yet because I'm having difficulty with this part. Obviously, <code>paste</code> returns a <code>character</code> rather than a <code>data.frame</code> for <code>data=b</code> but <code>cat</code> doesn't work either.</p>
  
  <p>Any help would be appreciated, if only to tell me that this is a repeat question.  (There are lots of similar questions but they haven't helped).</p>