title: Is there an efficient way to write the code snippet without for loops in R?
body: <p>Is there an efficient way to write the below code in R?</p>
  
  <p>v is a matrix of length n x n.</p>
  
  <pre><code>k &lt;- matrix(0, n, n-2)
  for (i in seq(n)){
    for (j in seq(n-2)) {
      k[i,j] = v[i, j]
    }
  }
  </code></pre>