0

I created model labels and model orders with vectors:

order <- c("modxyz", "modxzyy", "modsdfq")
label <- c("Model A", "Model B", "Model C")

And then use that to put them in a coefplot:

plot + 
scale_x_discrete(limits = order, labels = label)

And this works great! But, I have ~20 models, and after putting them all in order, I realized that it is in the reverse order from what I wanted them in (it puts the first model at the bottom instead of the top by default, which seems backwards to me?). Is there a way to easily reverse this order without rewriting both vectors, either within the vector code or within the scale_x_discrete() line?

tjebo
  • 21,977
  • 7
  • 58
  • 94
a_todd12
  • 449
  • 2
  • 12
  • 3
    Does this answer your question? [How to reverse order a vector?](https://stackoverflow.com/questions/18933441/how-to-reverse-order-a-vector) – tjebo Mar 19 '22 at 13:00

1 Answers1

2

Somehow I never knew that rev() exists. So:

rev_order <- rev(order)
rev_label <- rev(label)
a_todd12
  • 449
  • 2
  • 12