replace values on condition in R
<p>I want o replace values in two attributes in a dataframe. <code>CheckIn</code> and <code>CheckOut</code>. '--' should be replaced by NA where one of these two attribute value is missing. I tried to put some conditional logic and apply functions but failed. finally i tried using for loop.</p>

<pre><code>for(i in length(Empl.A)){
if((Empl.A$CheckIn[i]  == '--') &amp; (Empl.A$CheckOut[i] == '--'))
{
  Empl.A$CheckIn[i] &lt;- NA
  Empl.A$CheckOut[i] &lt;- NA
}
}
</code></pre>

<p><a href="https://i.stack.imgur.com/lz9Dw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lz9Dw.png" alt="enter image description here"></a></p>

<p>please refer me to some useful resource on replacing values Or to solve these kind of problems.</p>