title: R: matrix error
body: <p>In R, I'm simulating variable following a Wiener process.</p>
  
  <pre><code>mcsim &lt;- function(drift, dt, spot, spotdate, nap, maturity, sim)
  {
    for(n in 1:sim)
    {
      for(i in 1:maturity)
      {
        dz = rnorm(1, mean=0, sd=1);
        ivol = findnap(spot[i,n], spotdate[i], nap)
        ret = (drift-(ivol^2)/2)*dt+ivol*sqrt(dt)*dz;
        spot[i+1,n] = spot[i,n]*exp(ret);
  
        #display counter
        cat(n/sim, "% of 100% \r");
        #flush.console()
      }
    }
    return(spot);
  }
  </code></pre>
  
  <p><code>ivol</code> is a real, e.g. 0.23
  <code>ret</code> is a real too</p>
  
  <p>the error seems to be in the line : <code>spot[i+1,n] = spot[i,n]*exp(ret);</code></p>
  
  <pre><code>&gt;Error in FR : le nombre d'objets à remplacer n'est pas multiple de la taille du remplacement
  
  &gt;Error in EN : the number of objects that must be replaced is not a multiple of the size of the replacement. (sorry for the rough translation)
  </code></pre>