Replace all values in a data.table given a condition
<p>How would you replace all values in a data.table given a condition?</p>

<p>For example   </p>

<pre><code>ppp &lt;- data.table(A=1:6,B=6:1,C=1:6,D=3:8)

A B C D
1 6 1 3
2 5 2 4
3 4 3 5
4 3 4 6
5 2 5 7
6 1 6 8
</code></pre>

<p>I want to replace all "6" by NA</p>

<pre><code>A B C D
1 NA 1 3
2 5 2 4
3 4 3 5
4 3 4 NA
5 2 5 7
NA 1 6 8
</code></pre>

<p>I've tried something like</p>

<pre><code>ppp[,ifelse(.SD==6,NA,.SD)]
</code></pre>

<p>but it doesn't work, it produces a much wider table.</p>