title: How can I insert values into a data frame dynamically using R
body: <p>After scraping some review data from a website, I am having difficulty organizing the data into a useful structure for analysis. The problem is that the data is dynamic, in that each reviewer gave ratings on anywhere between 0 and 3 subcategories (denoted as subcategories "a", "b" and "c"). I would like to organize the reviews so that each row is a different reviewer, and each column is a subcategory that was rated. Where reviewers chose not to rate a subcategory, I would like that missing data to be 'NA'. Here is a simplified sample of the data:</p>
  
  <pre><code>vec &lt;- c("a","b","c","stop", "a","b","stop", "stop", "c","stop")
  ratings &lt;- c(2,5,1, 1,3, 2) 
  </code></pre>
  
  <p>The vec contains the information of the subcategories that were scored, and the "stop" is the end of each reviewers rating. As such, I would like to organize the result into a data frame with this structure. Expected Output</p>
  
  <p><a href="https://i.stack.imgur.com/8nKyJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8nKyJ.png" alt="enter image description here"></a></p>
  
  <p>I would greatly appreciate any help on this, because I've been working on this issue for far longer than it should take me..</p>