title: For loop in R return error 'object not found'
body: <p>I'm learning R and have written my first for-loop. For 1000 iterations I create 4 vectors, each with the dimensions 10, 100, 1000  and 10000 elements. These so called theta1 values are not recognised. I tried running one theta1 at the time and it works but running all 4 gives the error 'object not found'. It's not obvious to me what's wrong here, can anyone explain?</p>
  
  <pre><code>k=1000
  
  'Method1'
  
  for(i in 1:k){
    N10=runif(10) 
    N100=runif(100)
    N1000=runif(1000)
    N10000=runif(10000)
    theta1_10[i]=(1/10)*4*sum(sqrt(1-N10^2))
    theta1_100[i]=(1/100)*4*sum(sqrt(1-N100^2))
    theta1_1000[i]=(1/1000)*4*sum(sqrt(1-N1000^2))
    theta1_10000[i]=(1/10000)*4*sum(sqrt(1-N10000^2))
  }
  
  'Result Method 1'
  m_theta1_10 = mean(theta1_10)
  sd_theta1_10 = sd(theta1_10)
  m_theta1_100 = mean(theta1_100)
  sd_theta1_100 = sd(theta1_100)
  m_theta1_1000 = mean(theta1_1000)
  sd_theta1_1000 = sd(theta1_1000)
  m_theta1_10000 = mean(theta1_10000)
  sd_theta1_10000 = sd(theta1_10000)
  </code></pre>