title: How to interpret the code "x=numeric(n)"?
body: <p>I have codes in R, simulate Markov Chain</p>
  <pre><code>P = matrix(c(0,1,0,.2,0,.8,.1,.3,.6),nrow=3,byrow=T)
  n = 10000
  x = numeric(n)
  pi0 = c(.5, 0, .5)
  state = sample(1:3, 1, prob=pi0)
  x[1] = state
  for(i in 2:n){
    state = sample(1:3, 1, prob = P[state,])
    x[i] = stat
  }
  </code></pre>
  <p>x = numeric(n) looks like gives me 10000 zero number. What's the goal for numeric(n)? Why do I need many 0's?</p>
  <p>Help file said &quot;numeric is identical to double (and real). It creates a double-precision vector of the specified length with each element equal to 0.&quot; Maybe due to my English, I don't understand what does that mean.</p>