Подтвердить что ты не робот

Как изменить порядок панелей в простых графиках решетки

Привет, я использую следующий код для генерации 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,16,17,3),col=c(NA,"blue","red","green","purple")),
 space="right")
 )

Это дает мне следующий сюжет: enter image description here

Теперь после изменения кода для включения порядка панели, как предлагается:

xyplot(Rate~Weight|Temp, groups=Week, rate,
 index.cond=list(c(4,1,2,3)),#this provides the order of the panels
 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,16,17,3),col=c(NA,"blue","red","green","purple")),
 space="right")
 )

и получим правильный порядок enter image description here

Спасибо за помощь

4b9b3361

Ответ 1

Я преобразовал Temp в коэффициент и получил следующее:

enter image description here

Вы можете выровнять с таким же порядком порядка:

levels(rate$Temp) <- c("12", "9", "18", "15") #custom factor order