I have a dataframe and I would like to create a columns based on multiple conditions:
v1 v2 v3 v4 v5
4 1 2 4 5
5.5 2 4 5 6
21 9 20 30 50
6 4 5 7 9
10 3 6 5 9
Basically, create v6 with following possible values: Cat, dog, ant, hog
- If v1 is between v2 and v3, then cat
- If v1 is between v3 and v4, then dog
- If v1 is between v4 and v5, then ant
- If v1 is greater than v5, then hog.
I know how to do this for a single condition, but not multiple conditions.