[英]Order groups in a stacked stripchart by sum in R
I have a grouped and stacked stripchart()
in R
. 我在
R
有一个分组和堆叠的stripchart()
。
stripchart(gear ~ cyl, data=mtcars, method="stack")
cyl
are the groups here. cyl
是这里的团体。 I want to groups ordered by its sum. 我想要按其总和排序的团体。 From bottom to top the ordering should be 6, 4 and 8.
从下到上,排序应为6,4和8。
How can I do this automaticly in a stripchart
? 如何在
stripchart
自动执行此stripchart
?
As mentiont from Jota and with detailed help from How to order factors by condition in R? 正如Jota提到的那样,以及如何根据R中的条件订购因子的详细帮助?
Transforming cyl
into factor
and order it's levels. 将
cyl
转换为factor
并命令它的级别。
mtcars$cyl <- factor(mtcars$cyl, levels=names(sort(table(mtcars$cyl))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.