Hello all,
In order to get the desired order of panels within lattice I realized I needed 
to define my factor levels.
I now see how to properly do it (attached code), but:
1. I don't understand why I have to use factor() on a variable that is already 
a factor, and why levels() alone doesn't work to readjust the level order.
2. I just noticed that if I do use levels(xx$v1), it's changing something that 
can't be repaired with:
 xx$v1<-factor(xx$v1,levels=c('b','a','c')), and both plots are wrong.
I'm failing to grasp what levels() is doing compared to factor().
thanks very much.
Michael Folkes
 
#__________________________________
 
xx<-data.frame(v1=rep(letters[1:3],rep(3,3)),v2=rep(1:3,3),v3=rep(1:3,rep(3,3)))
str(xx)
levels(xx$v1)
 
#INCORRECT:
#if I run this level(), the factor() below doens't work properly
#levels(xx$v1)<-c('b','a','c')
xx
g1<-xyplot(v3~v2|v1,data=xx)

#CORRECT:
xx$v1<-factor(xx$v1,levels=c('b','a','c'))
g2<-xyplot(v3~v2|v1,data=xx)
xx
print(g1,split=c(1,1,2,1),more=T)
print(g2,split=c(2,1,2,1),more=F)

 
 
_______________________________________________________
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans     
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053  michael.fol...@dfo-mpo.gc.ca 
<mailto:michael.fol...@dfo-mpo.gc.ca> 

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to