lundi 29 mars 2021

Nested ifelse statement with multiple selection criteria

YDST Year
0 2020
1 2020
2 2020
3 2020
4 2020
5 2020
6 2020
7 2020
8 2020
9 2020
10 2020
0 2021
1 2021
2 2021
3 2021
4 2021
5 2021
6 2021
7 2021
8 2021
9 2021
10 2021

I have a data frame ('df') where I want to create a new column ('Students') where 'ns' indicates no students and 's' indicates students. However where 'ns' and 's' occur differs between years based on 'YDST'. For instance, in 2020 'ns' should be indicated from 0-3 and 9-10. In 2021, 'ns' should be indicated from '1-4', '6-7', and '9-10'.

How can I write a nested ifelse statement to not only account for 'Year', but also the different 'YDST' selection criteria between years?

Thank you!

Aucun commentaire:

Enregistrer un commentaire