How to change the order of x-axis in multiple boxplots in R

后端 未结 1 1119
不思量自难忘°
不思量自难忘° 2021-01-23 00:27

I am trying to change the order x-axis in this boxplot.

[Now the order is loupe, microscope and video, and I want to change it to microscope, loupe then video]

T

相关标签:
1条回答
  • 2021-01-23 01:21

    You will need to redefine the order of the factors with the factor function.

    #Sample data
    Label<-c("Microscope", "Microscope", "Loupe", "Loupe", "Video", "Video")
    mydata<-data.frame(Label)
    
    #print out
    levels(mydata$Label)
    
    mydata$Label<-factor(mydata$Label, levels=c("Microscope", "Loupe",  "Video"))
    #print out
    levels(mydata$Label)
    

    See the cookbook-r.com for more information: http://www.cookbook-r.com/Manipulating_data/Changing_the_order_of_levels_of_a_factor/

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