I am trying to decode some poker hands. In poker, each player plays in a named position, and each position has its own strategy. I need to label each position to study each strategy.
There are 6 possible positions:
Position 1 = Big blind
Position 2= Small Blind
Position 3= Button
Position 4= Cutoff
Position 5 = Middle Position
Position 6= Early Position
I have something like this:
df<-data.frame(text=c("Seat 1: Player M ($0.49 in chips)",
"Seat 2: Player X ($2.05 in chips)",
"Seat 3: Player L ($2.08 in chips)",
"Seat 5: Player J ($1.96 in chips)",
"Seat 6: Player W ($0.43 in chips)",
"Player X: posts small blind",
"Player L: posts big blind"))
In this example, players are ordered how they are seated (note that a Seat might be empty, like Seat 4)
I would like to number them based on their position relative to the strategy named before, so in this case i would have:
Player L woulb be "1" (Big Blind),
Player X would be "2" (Small Blind)
Player M would be "3" (Button)
Player W would be "4" (Cutoff)
Player J would be "5" (Middle Position)
Since there are only 5 players, there would not be position 6.
I am not sure how to do this. I think I would need to:
- Reorder them, based on that relative position of the one that has ": posts big blind" , that would be the number one.
- Number the rows based on that order.
There is any way to order based on a relative position?
expected<-data.frame(text=c("Seat 3: Player L ($2.08 in chips)",
"Seat 2: Player X ($2.05 in chips)",
"Seat 1: Player M ($0.49 in chips)",
"Seat 6: Player W ($0.43 in chips)",
"Seat 5: Player J ($1.96 in chips)"),
number=c(1,2,3,4,5))