title: Simple for loop in R producing "replacement has length zero" in R
body: <p>I am a novice in R, and so what seemed to work fine in C and Python, surprisingly breaks down in R.
  I am trying to calculate the product of the first 1000 Fibonacci numbers. Here is the full code:</p>
  
  <pre><code>#PRRODUCT OF FIBONACCI NUMBERS
  Fibonacci&lt;-rep(0, 1000)
  Fibonacci[0]&lt;-1
  Fibonacci[1]&lt;-1
  Product&lt;-1
  
  for (i in 2:1000)
  {
      Fibonacci[i]&lt;-(Fibonacci[i-1])+(Fibonacci[i-2])
      Product&lt;-Fibonacci[i]*Product
  }
  
  Fibonacci[1000]
  Product
  </code></pre>
  
  <p>This returns the following error: </p>
  
  <pre><code>Error in Fibonacci[i] &lt;- (Fibonacci[X - 1]) + (Fibonacci[X - 2]) : 
    replacement has length zero
  </code></pre>
  
  <p>I am inclined to think I have misunderstood operating with different elements of an array (perhaps the i-2 in the vector description is not correct), but I haven't found anything over the past hour and a half which would have helped me correct it. 
  So, any insights into the cause of the problem would be most appreciated.</p>
  
  <p>Thank you in advance.</p>