title: Convert Rows into Columns by matching string in R
body: <p>I have number of rows in a list like '</p>
  
  <pre><code>[1,]  "Home"
  [2,]  "A"
  [3,]  "B"
  [4,]  "C"
  [5,]  "Home"
  [6,]  "D"
  [7,]  "E"
  [8,]  "Home"
  [9,]  "F"
  [10,] "G"
  [11,] "H"
  [12,] "I"
  </code></pre>
  
  <p>these rows are coming dynamically...after "Home" there can be two,three,four,five or more subcategories....so binding is not working... I have more than 5000 rows and "Home" is common in the start for every subcategories..</p>
  
  <p>I Want it to look like this.     </p>
  
  <pre><code>       [,1]   [,2] [,3] [,4] [,5]
  
  [1,]  "Home"  "A"  "B"  "C"   
  [2,]  "Home"  "D"  "E"
  [3,]  "Home"  "F"  "G"  "H"  "I"
  </code></pre>
  
  <p>OR</p>
  
  <p>I have also used transpose to covert all rows into columns 
  and on using transpose I got.</p>
  
  <pre><code>   [,1]    [,2] [,3] [,4]  [,5]   [,6]  [,7]  [,8]   [,9] [,10] [,11] [,12]
  
     "Home"  "A"  "B"  "C"  "Home"   "D"   "E"  "Home"  "F"  "G"   "H"   "I"
  </code></pre>
  
  <p>any solution would work for me either converting rows in to columns using string match of "Home"<br>
  or 
  covert columns into rows using "Home" string match(transpose one)....</p>
  
  <p>Data</p>
  
  <pre><code>x &lt;- c("Home", "A", "B", "C", "Home", "D", "E", "Home", "F", "G", "H", "I")
  x &lt;- matrix(x)
  </code></pre>
  
  <p>The question has been solved...Thankyou for your response...
  I did it other way around...by running it in a loop and adding the row after every single node ends   </p>
  
  <pre><code>List &lt;- c() 
  
  #loop start
  nodes &lt;- html_nodes(file,".class a b c ") %&gt;% html_text()
  List[[length(List)+1]] = nodes      
  #loop ends
  
  library(stringi)
  catdf &lt;- stri_list2matrix(List, byrow = TRUE)
  catdf &lt;- as.data.frame(catdf)
  </code></pre>