Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在一个箱线图上对方框进行排序?(r)_R_Boxplot - Fatal编程技术网

如何在一个箱线图上对方框进行排序?(r)

如何在一个箱线图上对方框进行排序?(r),r,boxplot,R,Boxplot,我已经阅读了这类问题的答案,很抱歉重复,但我很难理解它们是如何应用于我的数据布局的 我想要的是按照我希望的顺序而不是字母顺序排列箱线图上的方框(比如说,有四个方框) 这是我当前代码的简化版本: TotalPer = c(1, 4, 6, 17, 4, 12) IntPer = c(3, 8, 10, 1, 4, 8) DomPer = c(4, 5, 10, 20, 13, 12) IntDomBox <- data.frame(y=c(TotalPer,IntPer,DomPer),

我已经阅读了这类问题的答案,很抱歉重复,但我很难理解它们是如何应用于我的数据布局的

我想要的是按照我希望的顺序而不是字母顺序排列箱线图上的方框(比如说,有四个方框)

这是我当前代码的简化版本:

TotalPer = c(1, 4, 6, 17, 4, 12)
IntPer = c(3, 8, 10, 1, 4, 8)
DomPer = c(4, 5, 10, 20, 13, 12)

IntDomBox <- data.frame(y=c(TotalPer,IntPer,DomPer),
x=c(rep("Total",length(TotalPer)),rep("International",length(IntPer)),
rep("Domestic",length(DomPer))))
with(IntDomBox, boxplot(y~x, main = "Prediction Residuals", ylab="%",
par(cex.axis=0.7)))
TotalPer=c(1,4,6,17,4,12)
IntPer=c(3,8,10,1,4,8)
DomPer=c(4,5,10,20,13,12)

IntDomBox多种可能性中的一种:在打印之前,通过执行
IntDomBox$x对因子级别进行重新排序太好了,谢谢!我不确定如何将其标记为答案,因为这是一条评论,所以我可能稍后会将其重写为答案