title: How to prevent running i=j in double for loops in R?
body: <p>I want to prevent running the <code>i=j</code> case and substitute it as <code>NA</code> in <code>R</code>. Here I prepared a small example. When <code>i=j</code>, I have the output <code>0</code>. But I want to print it as <code>NA</code>. How can I do this one? Thanks.</p>
  <pre><code>n = 5
  for(j in 1:(n-1)){
    for(i in 0:(n-2)){
      print(2^(abs(i-j)))
    }
  }
  </code></pre>
  <p>The outputs are <code>2, 1, 2, 4,...</code>.</p>