I have a data table as follows:
x y z
1 head car toe
2 hand nose mouse
3 key house ball
now I want to shift head, hand and ball to a new column and delete the word in the existing columns:
x y z new
1 car toe head
2 nose mouse hand
3 key house ball
Could you help me out please? Thank you very much.
Reproducible Data:
df <- data.frame(
V1 = 1:3,
x = c("head", "car", "toe"),
y = c("hand", "nose", "mouse"),
z = c("key", "house", "ball")
)