I have a dataframe of chess games with two columns as shown below
dd <- data.frame(
game_id = c(101,102),
moves = c("1.e4 c5 2.Nf3 d6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 Nc6 6.Bc4 e6 7.Be3 Be7","1.e3 c5 2.Nf3 Nc6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 e5 6.Ndb5 d6")
)
Here each row is a separate game uniquely identified by the game id. The moves column contain all the moves of a game in sequential order from left to right. The serial number of the move can be identified by the number just before each dot ".". Each move has two parts; the first part is always the move by the white player followed by the second part which is the move by the black player. The two parts are separated by a single space. As shown in the above data, two consecutive moves are also separated by a single space, however, there is no gap between the dot of the serial number and the first character of the white player's move. The total number of moves in a game is arbitrary as some games end in a few moves while others may have many moves.
Question: As we can see all the moves of a game are present in one single cell of the dataframe which is not very easy for analysis. I want to convert this to a dataframe with a better structure as shown below:
game_id | move_no | white | black
----------------------------------
101 | 1 | e4 | c5
101 | 2 | Nf3 | d6
101 | 3 | d4 | cxd4
101 | 4 | Nxd4 | Nf6
How can this be done in R?