x y
2 4
5 8
1 4
9 12
I have four conditions
- maxx = 3, minx = 1, maxy = 6, miny = 3. (If minx < x < maxx and miny < y < maxy, then z = apple)
- maxx = 6, minx = 4, maxy = 9, miny = 7. (If minx < x < maxx and miny < y < maxy, then z = ball)
- maxx = 2, minx = 0, maxy = 5, miny = 3. (If minx < x < maxx and miny < y < maxy, then z = pine)
- maxx = 12, minx = 7, maxy = 15, miny = 11. (If minx < x < maxx and miny < y < maxy, then z = orange)
Expected outcome:
x y z
2 4 apple
5 8 ball
1 4 pine
9 12 orange
I have thousands of rows, and these four conditions that will fit all values.
How can I do this using the mutate function? I know how to manipulate numbers directly, but not sure how I can store a character based on conditional statements.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…