Hello,
I have a dataset where there are places visited listed in a descending order (variables A_1/2/3 in my example).
I would like to find an automated way to rearrange this order to be in an ascending order (variables B_1/2/3 in my example).
Could you think of a different way to describe your requirements?
its quite confusing...
if I sort the df you provide.
df %>% select(sort(names(df)))
A_1 A_2 A_3 B_1 B_2 B_3
1 f d a f d a
2 <NA> e b e b <NA>
3 <NA> <NA> c c <NA> <NA>
how should this be understood. what is being rearranged to what in descending order?
is the first row to be unchanged, and only the second and third rows show difference ?
are we just sliding non missing values to the left ?
This solution relies on assumption that the NA's/values across a row are contigious. i.e. NA's wont be to the right of any values on the starting dataframe.