split strings and add them as new row
<p>I have the following dataset: </p>

<pre><code>df&lt;-data.frame (fact= c("a,b,c,d","f,g,h,v"), value = c("0,1,0,1" , "0,0,1,0"))
</code></pre>

<p>This is the data:</p>

<pre><code>   fact   value
1 a,b,c,d 0,1,0,1
2 f,g,h,v 0,0,1,0
</code></pre>

<p>I wish to split it when the <strong>value is 1</strong>. So, my ideal output is: </p>

<pre><code> fact     value

1:  a,b     0,1
2:  c,d     0,1
3: f,g,h    0,0,1
4:  v       0
</code></pre>

<p>Firstly, I thought I might find a way by using <code>cut</code> like: </p>

<pre><code>cut(as.numeric(strsplit(as.character(df$value), split = ",")), breaks =1)
</code></pre>

<p>But none of my attempts get close. </p>