Let's say I have a data.frame with three rows: x, y, and f(x,y). The x and y are gridded at integer values (i.e. indices to a matrix). Is there a clean way in R to from this three column thing to a matrix of f(x,y) values in which each entry corresponds to the (x,y,f(x,y)) triplet I had before? I'd like to avoid doing a for-loop, although that is of course an easy option.
I.e. if that wasn't clear, I'd like to go from:
x, y, f.x_y;
1, 1, 3.1;
1, 2, 35.5;
1, 3, 4.4;
2, 1, 3.1;
2, 2, 3.3;
2, 3, 5.5;
3, 1, 24.1;
3, 2, 3.14;
3, 3, 3.55;
---- To -----
3.1, 3.1, 24.1;
35.5, 3.3, 3.14;
4.4, 5.5, 3.55