title: How to create a vector of character strings using a loop?
body: <p>I am trying to create a vector of character strings in R using a loop, but am having some trouble. I'd appreciate any help anyone can offer.</p>
  
  <p>The code I'm working with is a bit more detailed, but I've tried to code a reproducible example here which captures all the key bits:</p>
  
  <pre><code>vector1&lt;-c(1,2,3,4,5,6,7,8,9,10)
  vector2&lt;-c(1,2,3,4,5,6,7,8,9,10)
  thing&lt;-character(10)
  
  
  for(i in 1:10) {
    line1&lt;-vector1[i]
    line2&lt;-vector2[i]
    thing[i]&lt;-cat(line1,line2,sep="\n") 
  }
  </code></pre>
  
  <p>R then prints out the following:</p>
  
  <pre><code>1
  1
  
  Error in thing[i] &lt;- cat(line1, line2, sep = "\n") : 
    replacement has length zero
  </code></pre>
  
  <p>What I'm trying to achieve is a character vector where each character is split over two lines, such that <code>thing[1]</code> is</p>
  
  <pre><code>1
  1
  </code></pre>
  
  <p>and <code>thing[2]</code> is</p>
  
  <pre><code>2
  2
  </code></pre>
  
  <p>and so on. Does anyone know how I could do this? </p>