Sort boxplot by mean (and not median) in R

前端 未结 1 1642
梦谈多话
梦谈多话 2020-12-16 17:42

I have a simple boxplot, showing the distribution of a score for factor TYPE:

myDataFrame = data.frame( TYPE=c(\"a\",\"a\",\"b\",\"b\",\"c\",\"c\"), SCORE=c(         


        
相关标签:
1条回答
  • 2020-12-16 18:15

    This is a job for reorder():

    myDataFrame$TYPE <- with(myDataFrame, reorder(TYPE, SCORE, mean))
    boxplot( SCORE~TYPE, data=myDataFrame )
    

    enter image description here

    0 讨论(0)
提交回复
热议问题