Order groups in a stacked stripchart by sum in R

戏子无情 提交于 2019-12-11 06:08:15

问题


I have a grouped and stacked stripchart() in R.

stripchart(gear ~ cyl, data=mtcars, method="stack")

cyl are the groups here. I want to groups ordered by its sum. From bottom to top the ordering should be 6, 4 and 8.

How can I do this automaticly in a stripchart?


回答1:


As mentiont from Jota and with detailed help from How to order factors by condition in R?

Transforming cyl into factor and order it's levels.

mtcars$cyl <- factor(mtcars$cyl, levels=names(sort(table(mtcars$cyl))))


来源:https://stackoverflow.com/questions/42426970/order-groups-in-a-stacked-stripchart-by-sum-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!