I am trying to analyze some daily fantasy lineups and need to split the lineup column into multiple columns, one for each position.
I would like the delimiters to be the positions ("P", "C", "1B", "2B", "SS", "3B", "OF").
I have tried to use str_split and separate but am slightly confused on how I would go about to get them into separate columns and then ordered.
Here is the column that I want to split:
Lineup
1B Justin Bour P José Berríos P Justin Verlander 2B Kiké Hernández OF Cody Bellinger OF Joc Pederson C Austin Barnes SS Corey Seager OF Corey Dickerson 3B Jung Ho Kang
P José Berríos OF Albert Almora Jr. SS Javier Báez 3B Kris Bryant 2B Ben Zobrist 1B Anthony Rizzo OF Cody Bellinger OF Joc Pederson C Austin Barnes P Eric Lauer
I would like this to look like:
P | P | C | 1B | 2B .. and so on...
------------- | ----------------- | --------------- | --------------- |
José Berríos | Justin Verlander | Austin Barnes | Justin Bour |
José Berríos | Eric Lauer | Austin Barnes | Anthony Rizzo |