Questions tagged [relocate]
5 questions
9
votes
5 answers
Relocate rows with tidyverse
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),…

TarJae
- 72,363
- 6
- 19
- 66
2
votes
3 answers
How can I relocate mutated columns next to the original colums?
I have made a function which mutates across columns and creates new named columns from each of them. The new colums are put to the right side of the dataframe whereas I would like to have them adjacent to each of the original columns. I am looking…

Mico Hamlyn
- 23
- 4
0
votes
1 answer
How to relocate column names based on a specific order, if some names are missing in the dataframe
I am trying to use the relocate() function to reorder the columns of a dataframe based on a specific order. The order is not alphabetical. E.g.
Red
Yellow
Green
Brown
Blue
Pink
Black
White
The data could be different each time it is loaded…

erwalker
- 1
0
votes
1 answer
How to relocate the position on the map (ggplot/sf/geometry)
I am using R to draw a map of China and the USA. I would like to map the "holistic thinking" across these two countries. Could you help me with the followings?
relocate these two countries? There is too much space between the two countries. I would…
0
votes
4 answers
Move several chunks of columns dynamically to another position
My data is:
df <- data.frame(a = 1:2,
x = 1:2,
b = 1:2,
y = 3:4,
x_2 = 1:2,
y_2 = 3:4,
c = 1:2,
x_3 = 5:6,
…

deschen
- 10,012
- 3
- 27
- 50