如何在简单的格子图中更改面板的顺序

问题描述

|| 嗨,我正在使用以下代码使用晶格生成xyplot
xyplot(Rate~Weight|Temp,groups=Week,rate,pch=c(15,16,17,3),col=c(\"blue\",\"red\",\"green\",\"purple\"),as.table=TRUE,xlab=\"Weight (gr)\",ylab=\"Rate (umol/L*gr)\",main=\"All individuals and Treatments at all times\",strip=strip.custom(strip.names=1),key=
 list(text=list(c(\"Week\",\"1\",\"2\",\"6\",\"8\")),points=list(pch=c(NA,15,col=c(NA,\"blue\",\"purple\")),space=\"right\")
 )
这给了我以下情节: 现在,按照建议更改代码包括面板顺序后:
xyplot(Rate~Weight|Temp,index.cond=list(c(4,1,2,3)),#this provides the order of the panels
 pch=c(15,space=\"right\")
 )
我们得到正确的订单 谢谢您的帮助     

解决方法

        我将
Temp
转换为因数,得到了这个: 您可以像这样按因子顺序进行调整:
levels(rate$Temp) <- c(\"12\",\"9\",\"18\",\"15\") #custom factor order