Interpolate missing values of a data frame
<p>I have a dataset like this:</p>

<pre><code>x   y   z
1   1   0.954
1   3   0.134
1   30  0.123
2   1   0.425
2   3   0.123
2   30  0.865
5   1   0.247
5   3   0.654
5   30  0.178
</code></pre>

<p>Let's think of this as the height of a surface sampled at 9 points over a 4x29 field. Suppose I want to fill in the missing values by interpolating (linear is fine), so that I end up with a z value for every (integer) x in [1,5] and every y in [1,30]. I want the result to still be a data frame with the same structure.</p>

<p>How can I do this in R?</p>