I have a dataframe that contains a rating column.
I would like to sort using a custom order, e.g. AAA, AA, A, BBB, BB, B
However, default R sorting (using dplyr::arrange) results in A AA AAA B BB BBB
data.frame(Rating=c('AAA','AA','A','B','BB','BBB'), Value1=c(1,2,3,4,5,6), Value2=c(2,3,4,5,3,2)) %>% arrange(Rating) I found many links referring to same problem but they are not related to dataframe eg customize the sort function in R
How can I sort my data using a custom order?