[R] re-ordering x-lables using barchart()

David Winsemius dwinsemius at comcast.net
Tue Dec 8 23:03:30 CET 2009


On Dec 8, 2009, at 4:42 PM, Gary Miller wrote:

> Hi R Users,
>
> I'm trying to re-order the "site names" ("Waseca", "Morris", ...).  
> I'm using
> following code:
>
> libarry(lattice)

# slip this code (or one with your preferred ordering) in before the  
plot call:

  barley$site <- factor(barley$site, levels = c("Waseca","Morris",  
"Crookston"  , "University Farm","Grand Rapids" ,   "Duluth"))

> barchart(yield ~ variety | site, data = barley,
>              groups = year, layout = c(6,1), aspect=.7,
>              ylab = "Barley Yield (bushels/acre)",
>              scales = list(x = list(abbreviate = TRUE, rot=45,  
> minlength =
> 5)))

Comes out with rather squished labels although stretching the window  
helps.

>
> Can anyone help please.
>
> -Gary
>


David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list