My data looks like this
win_loss_table<- data.frame(Player = c("A","B","C","D","E","A","C"),Status = c("A","C","D","Draw","E","C","D"))
> win_loss_table
Player Status
1 A A
2 B C
3 C D
4 D Draw
5 E E
6 A C
7 C D
The transformed table should look like this
desired_table <- data.frame(Player = c("A","B","C","D","E","A","C"), Status= c("Won","Lost","Lost","Draw","W0n","Lost","Lost"))
> desired_table
Player Status
1 A Won
2 B Lost
3 C Lost
4 D Draw
5 E Won
6 A Lost
7 C Lost
However using the following code I am getting a data frame like this which is incorrect
incorrect_table<- data.frame(Player = c("A","B","C","D","E","A","C"),Status=as.factor(ifelse(win_loss_table$Status == "Draw","Draw",ifelse(win_loss_table$Player %in% win_loss_table$Status,"Won","Lost"))))
>incorrect_table
Player Status
1 A Won
2 B Lost
3 C Won
4 D Draw
5 E Won
6 A Won
7 C Won
Any help on where I am going wrong willl be greatly appreciated