[R] bwplot scales in alphabetical order

Tim Clark mudiver1200 at yahoo.com
Wed Sep 30 19:03:39 CEST 2009


Peter,

Thanks, that did it!

Tim


Tim Clark
Department of Zoology 
University of Hawaii


--- On Wed, 9/30/09, Peter Ehlers <ehlers at ucalgary.ca> wrote:

> From: Peter Ehlers <ehlers at ucalgary.ca>
> Subject: Re: [R] bwplot scales in alphabetical order
> To: "Tim Clark" <mudiver1200 at yahoo.com>
> Cc: r-help at r-project.org
> Date: Wednesday, September 30, 2009, 2:43 AM
> Tim,
> 
> Add the argument as.table=TRUE to your call:
> 
>   bwplot(y~x|id, horizontal=FALSE, as.table=TRUE)
> 
> Peter Ehlers
> 
> Tim Clark wrote:
> > Dear List,
> > 
> > I know this has been covered before, but I don't seem
> to be able to get it right.  I am constructing a
> boxplot in lattice and can't get the scales in the correct
> alphebetical order.  I have already read that this is
> due to the way factors are treated, and I have to redefine
> the levels of the factors.  However, I have
> failed.  As a simple example:
> > 
> > library(lattice)
> > id<-rep(letters[1:9], each=20)
> > x<-rep(seq(1:10),each=18)
> > y<-rnorm(180,50,20)
> > 
> > #Reverse alphebetical order
> >   bwplot(y~x|id, horizontal=FALSE)
> > 
> > #alphebetical order reading right to left
> >   id<-factor(id,levels =
> sort(id,decreasing = TRUE))
> >   bwplot(y~x|id, horizontal=FALSE)
> > 
> > It appears that bwplot plots scales from the bottom
> left to the top right. If so my factor levels would need to
> be levels=c(7,8,9,4,5,6,1,2,3). I tried that but can't seem
> to get the factor function to work.
> > 
> > #Did not work!
> >
> id<-factor(id,levels=c(7,8,9,4,5,6,1,2,3),lables=letters[1:9])
> > 
> > Your help would be greatly appreciated.
> > 
> > Tim
> > 
> > 
> > 
> > 
> > 
> > Tim Clark
> > Department of Zoology University of Hawaii
> > 
> > ______________________________________________
> > R-help at 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.
> > 
> > 
> 







More information about the R-help mailing list