0

So let's say we have the following arbitrary tibble:

Header_A  Header_B  Header_C
 1          A          10
100         A          15
 10         F          C
 K          B          Q

Now, let's say we have the following list order = c('B','F','A'). I am wondering how to go about re-arranging the tibble by Header_B according to the order in order. In other words, this would be the expected output:

Header_A  Header_B  Header_C
 K          B          Q
 10         F          C
 1          A          10
100         A          15

The internal order of A does not matter. I'm a very inexperienced user of R so I don't really know how to go about it. I was trying to just re-arrange the tibble by descending alphabetical order of B by calling tibble %>% arrange (desc('Header_B'))but nothing changed.

In Python equivalency, if this were a dataframe, it would be possible to accomplish this by sort_values(by='header_B), key=order. I guess I am looking for something similar.

Thanks in advance,

RDoc
  • 346
  • 1
  • 10

0 Answers0