title: Is there a way to refer a variable when the variable name has a number in it
body: <p>In the following assignment : assign(paste("orca", i, sep = ""), list_name[[i]]), the variable name contains number based on the value of i. Now if I want to perform an operation on say orca1, orca2 till orcan. How do I refer it using a variable(i) once again.</p>
  
  <pre><code>x &lt;- 1
  y &lt;- 0
  for (i in 1:10)
  {
    x &lt;- x*0.8
    y &lt;- y + x*orca'i'
  }
  </code></pre>
  
  <p>I want to achieve the following:</p>
  
  <p>y = 0.8 * orca1 + 0.8^2 * orca2 + 0.8^3 * orca3 +..+ 0.8^10 * orca10</p>
  
  <p>How do I do it?
  Is there any other way to do this as well</p>
  
  <p>Edit: I have tried using a list as follows as I heard it is a more appropriate way to use as follows:</p>
  
  <pre><code>x &lt;- seq(1:50)
  y &lt;- 1
  orcasum &lt;- 0
  orca &lt;- list()
  for(i in 1:10)
  {
    y &lt;- y*0.8
    orca[i] &lt;- y*lag(x,i)
    orcasum &lt;- orcasum + orca[i]
  }
  </code></pre>
  
  <p>I tried the above code to achieve the same expected result as earlier. The problem I faced here is: "In orca[i] &lt;- y*lag(x,i) : number of items to replace is not a multiple of replacement length".</p>
  
  <p>How do I proceed now?</p>