R: how to use a variable in a loop? A1, A2, A3
<p>A small example. I created 'A1', 'A2', ..., 'A10', in the first loop. I want to get the mean of them in another loop? how should I do that?</p>

<pre><code>d= 5
for(i in 1:10) 
{ 
  nam &lt;- paste("A", i, sep = "")
  assign(nam, rnorm(3)+d)
}

for(i in 1:10)
{
  nam &lt;- paste("A", i, sep = "")
  mean(nam)
}
</code></pre>

<p>the above doesn't work because nam is a string.</p>

<p>Thanks,
PS</p>