Boxlot以平均值排列 [英] Boxplots ranked by mean value

查看:239
本文介绍了Boxlot以平均值排列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示多个变量的箱型图,并按照降序排列它们,就像在 Performance Analytics 包中一样。我使用下面的代码来生成箱形图:

  zx<  -  replicate(5,rnorm(50))
zx_means < - (colMeans(zx,na.rm = TRUE))
boxplot(zx,horizo​​ntal = FALSE,outline = FALSE)
points(zx_means,pch = 22,col =darkgrey ,lwd = 7)

到目前为止,我还没有能够想出一个方法来对它们进行排名如上所述。我尝试过使用 sort order ,但是目前为止没有任何令人满意的结果。



任何帮助都将倍受赞赏。

<$ c
$ b

  colnames(zx)< -  seq_len  c> order  (zx_means [order(zx_means)],pch = 22,col =
boxplot(zx [,order(zx_means)],horizo​​ntal = FALSE,outline = FALSE) darkgrey,lwd = 7)


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)

这篇关于Boxlot以平均值排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆