title: R command for summation over parametrized indices
body: <p>I'm trying to create a function in R so I command,</p>
  
  <pre><code>f &lt;- function(d,r,k) {
      A &lt;- d^(r-1)
      B &lt;- **summation over i going from r to (k-1)**d^2i
      return (A+B)
  }
  </code></pre>
  
  <p>I can not do the <strong>.</strong> part in the command above without help. So is there a command for summation where I can assign arbitrary parametric indices?</p>