I would like to show boxplots for multiple variables, and rank them by column means in descending order, just like in the Performance Analytics package. I use the following code to generate the boxplots:
zx <- replicate (5, rnorm(50))
zx_means <- (colMeans(zx, na.rm = TRUE))
boxplot(zx, horizontal = FALSE, outline = FALSE)
points(zx_means, pch = 22, col = "darkgrey", lwd = 7)
So far I have not been able to come up with a way to rank them as described above. I have tried using both sort and order, but without any satisfying results so far.
Any help would be much appreciated.
order works fine for me!?:
colnames (zx) <- seq_len (ncol (zx))
boxplot(zx [, order (zx_means)], horizontal = FALSE, outline = FALSE)
points(zx_means [ order (zx_means)], pch = 22, col = "darkgrey", lwd = 7)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With