I want an indicator variable that tells me if the date is the lowest or highest when its group by ID. However, I don't want it to count anything that has practice as 1. This is what the data frame looks now and what I want it to look like.
| ID | date | practice |
|---|---|---|
| 1 | 02-27-2020 | 1 |
| 1 | 04-21-2021 | 0 |
| 1 | 06-24-2022 | 0 |
| 2 | 03-21-2019 | 0 |
| 2 | 09-19-2020 | 0 |
| 2 | 01-21-2021 | 0 |
End product:
| ID | date | practice | lowest | highest |
|---|---|---|---|---|
| 1 | 02-27-2020 | 1 | 0 | 0 |
| 1 | 04-21-2021 | 0 | 1 | 0 |
| 1 | 06-24-2022 | 0 | 0 | 1 |
| 2 | 03-21-2019 | 0 | 1 | 0 |
| 2 | 09-19-2020 | 0 | 0 | 0 |
| 2 | 01-21-2021 | 0 | 0 | 1 |