Create a new variable base on other variables contain a specific value in r
<p>I have several time serious variables and I want to create two new dummy variables. 
Variable one: if other variables contain a specific value, then variable one equal 1.
Variable two: if other variables contain a specific value continuously, then variable two equal 1.</p>

<p>My data looks like</p>

<pre><code>ID score_2011 score_2012 score_2013 score_2014 score_2015
1          12         15         96         96         16
2          12         15         15         15         16
3          12         96         20         15         16
4          12         15         18         15         16
5          12         15         96         15         16
</code></pre>

<p>I want to get the new variables like the following</p>

<pre><code>IF score_2011~2015 contain 96 then with_96=1
IF score_2011~2015 contain continuous 96 then back_to_back_96=1 
</code></pre>

<p>I want the result to look like..</p>

<pre><code>  ID    score_2011 score_2012 score_2013  score_2014  score_2015  with_96  back_to_back_96
    1          12         15         96         96         16       1               1
    2          12         15         15         15         16       0               0
    3          12         96         20         15         16       1               0
    4          12         15         18         15         16       0               0
    5          96         15         96         15         16       1               0
</code></pre>

<p>Thanks in advance</p>