If I have a the following df
id | tiger | donkey | turtle |
---|---|---|---|
1 | 1 | 0 | 0 |
2 | 0 | 1 | 0 |
3 | 0 | 0 | 1 |
So that 1 equals True and 0 equals False.
And I want to create the following df
id | animal |
---|---|
1 | tiger |
2 | donkey |
3 | turtle |
How would I do this using dplyr
? I first thought that I could use pivot_long()
but I should not have more rows after the operation.