Is it possible to relocate rows in tidyverse framework like it is possible for columns with dplyr relocate?
In this example I would like to relocate row 1 to position 5 (end of dataframe)
My dataframe:
df <- structure(list(ID = c(1, 2, 3, 4, 5), var1 = c("a", "b", "c",
"d", "e"), var2 = c(1, 1, 0, 0, 1)), class = "data.frame", row.names = c(NA,
-5L))
df
ID var1 var2
1 1 a 1
2 2 b 1
3 3 c 0
4 4 d 0
5 5 e 1
Desired output:
ID var1 var2
1 2 b 1
2 3 c 0
3 4 d 0
4 5 e 1
5 1 a 1
Note: In the it should be 'pipe friendly' solution. I tried a lot but found nothing. Thank you.