Pig: How do I add a new value for a column for a subset of data?
<p>I have some data as follows:</p>

<pre><code>patient_id lab_value
1, 10
1, 3
2, 1
2, 4
3, 5
3, 10
3, 2
</code></pre>

<p>What I'd like to do is to find the max lab_value per patient_id grouping then ultimately calculate the difference between a lab_value and the max as follows.</p>

<pre><code>patient_id lab_value lab_diff
1, 10, 0
1, 3, 7 (10 - 3)
2, 1, 3 
2, 4, 0
3, 5, 5 (10 - 5)
3, 10, 0
3, 2, 8 (10 - 2)
</code></pre>

<p>How would I do this?</p>