How to split a column into 2 headings and fill with data from another column in R
05:27 13 Mar 2026

I currently have a data file that looks like this (simplified version)

RUNTIME PLANE ID COORDINATE
1 X A1 1
2 X A1 3
3 X A1 8
1 Y A1 2
2 Y A1 9
3 Y A1 3
1 X A2 2
2 X A2 4
3 X A2 6
1 Y A2 1
2 Y A2 7
3 Y A2 3

In R, how can I split the "PLANE" column into "XCOORDINATE" and "YCOORDINATE" i.e. all of the Xs as one column and all of the Ys as another column and fill it with the corresponding data from the column COORDINATE so that I would end up with a table that looks like this

RUNTIME ID XCOORDINATE YCOORDINATE
1 A1 1 2
2 A1 3 9
3 A1 8 3
1 A2 2 1
2 A2 4 7
3 A2 6 3

It is probably something simple, but I am really struggling to find an example code to work from that will do what I need.

r dataframe