title: How to split cell contents into several columns to create wide data?
body: <p>I have a data set, data come from a multiple selection question in a Google form. However, when data are exported, all options selected by respondents are put in a single column, separated by commas. Like this.</p>
  <pre><code>df &lt;- structure(list(teacher = c(&quot;Mary&quot;, &quot;Andrew&quot;, &quot;Rose&quot;, 
  &quot;Julia&quot;, &quot;Richard&quot;), grades = c(&quot;K, 1, 2, 3, 4&quot;, &quot;1, 3, 4&quot;, &quot;1, 2, 3, 4, 5&quot;, &quot;4, 5&quot;, 
  &quot;K, 1, 2, 3, 4, 5&quot;)), 
  class = &quot;data.frame&quot;, row.names = c(NA, -5L))
  </code></pre>
  <p>I would like to split the cell contents into several columns to create wide data, so the final table looks like this:</p>
  <pre><code>df.wide &lt;- structure(list(teacher = c(&quot;Mary&quot;, &quot;Andrew&quot;, &quot;Rose&quot;, 
  &quot;Julia&quot;, &quot;Richard&quot;), grade_k = c(1,0,0,0,1), grade_1 = c(1,1,1,0,1), grade_2 = 
  c(1,0,1,0,1), grade_3 = c(1,1,1,0,1), grade_4=c(1,1,1,1,1), grade_5 = c(0,0,1,1,1)), 
  class = &quot;data.frame&quot;, row.names = c(NA, -5L))
  </code></pre>
  <p>How can I do this in R. Thanks in advance for any help</p>