title: Assigning and removing objects in a loop: eval(parse(paste(
body: <p>I am looking to assign objects in a loop. I've read that some form of <code>eval(parse(</code> is what I need to perform this, but I'm running into errors listing <code>invalid text</code> or <code>no such file or directory.</code> Below is sample code of generally what I'm attempting to do:</p>
  
  <pre><code>x &lt;- array(seq(1,18,by=1),dim=c(3,2,3))
  for (i in 1:length(x[1,1,])) {
    eval(parse(paste(letters[i],"&lt;-mean(x[,,",i,"])",sep="")
  }
  </code></pre>
  
  <p>And when I'm finished using these objects, I would like to remove them (the actual objects are very large and cause memory problems later on...)</p>
  
  <pre><code>for (i in 1:length(x[1,1,])) eval(parse(paste("rm(",letters[i],")",sep="")))
  </code></pre>
  
  <p>Both <code>eval(parse(paste(</code> portions of this script return errors for <code>invalid text</code> or <code>no such file or directory</code>. Am I missing something in using <code>eval(parse(</code>? Is there a easier/better way to assign objects in a loop?</p>