Let's assume I have a dataset in following structure:
| ID | Event1_probability | Event2_probability | Event3_probability | Event4_probability |
| 1 | 0.1 | 0.05 | 0.12 | 0.15 |
| 2 | 0.21 | 0.03 | 0.11 | 0.17 |
I want to add information about which event is:
- most probable
- 2nd most probable
etc.
Per each row.
Therefore, I would like to achieve the following structure:
| ID | Event1_probability | Event2_probability | Event3_probability | Event4_probability | 1st_probability_event | 2nd_probability_event | 3rd_probability_event | 4th_probability_event |
| 1 | 0.1 | 0.05 | 0.12 | 0.15 | Event4 | Event3 | Event1 | Event2 |
| 2 | 0.21 | 0.03 | 0.11 | 0.17 | Event1 | Event4 | Event3 | Event2 |
How to achieve it without writing enourmous IF statements for each new column?
Thanks in advance for any help!